Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSE Navigation Sidebar: Move navigation sidebar in DOM hierarchy #25884

Merged
merged 24 commits into from Oct 15, 2020

Conversation

@jeyip
Copy link
Contributor

@jeyip jeyip commented Oct 6, 2020

Description

The focus order for the navigation panel wasn't behaving as expected. Shift+Tab from the back button did not focus the "Toggle Navigation" button, but rather the last element of the header toolbar instead.

Although consistent with the Inserter's behavior, Shaun has identified inserter behavior as a bug (source). The goal is to update the placement of the navbar toggle and panel so that focus navigation behaves as expected.

How has this been tested?

Site Editor

  1. Set up the site editor locally
  2. Navigate to the site editor
  3. Click on the navigation sidebar toggle
  4. Smoke test the navigation sidebar
    • Navigation panel closes correctly when toggle is used again
    • Dashboard button works correctly
    • Navigation panel items behave as expected (click on templates and template parts)
    • Styling matches what is in production
    • Responsiveness matches what is in production
    • After clicking on the navigation toggle, user can press the Shift + Tab keys to refocus the navigation toggle

Post Editor

  1. Navigate to the post editor
  2. Smoke test the page layout:
  • Page styling matches what is in production
  • Page layout matches what is in production
  • General responsiveness matches what is in production
  • Header
    • Is the header responsive?
    • Is the layout correct?
    • Is it fixed to the screen?
  • Body
    • Is the body responsive?
    • Can the block editor scroll?
    • Is the layout correct?
  • Footer
    • Is the header responsive?
    • Is the layout correct?
    • Is it fixed to the screen?
  • Left Sidebar (e.g. block inserter)
    • Is the layout correct?
    • Is it fixed to the screen?
  • Right Sidebar (e.g. block settings)
    • Is the layout correct?
    • Is it fixed to the screen?

Screenshots

Navigation Toggle Navigation Panel
Screen Shot 2020-10-06 at 4 49 05 PM Screen Shot 2020-10-06 at 4 49 11 PM

Before

2020-10-07 16 27 36

After

2020-10-07 16 25 01

Types of changes

Bug fix #25701

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.
@jeyip jeyip requested a review from youknowriad as a code owner Oct 6, 2020
@jeyip jeyip self-assigned this Oct 6, 2020
@jeyip jeyip marked this pull request as draft Oct 6, 2020
@jeyip jeyip removed the request for review from youknowriad Oct 6, 2020
@github-actions
Copy link

@github-actions github-actions bot commented Oct 6, 2020

Size Change: +314 B (0%)

Total Size: 1.19 MB

Filename Size Change
build/block-editor/index.js 130 kB -4 B (0%)
build/block-library/index.js 142 kB +2 B (0%)
build/components/index.js 169 kB +1 B
build/edit-post/index.js 306 kB +46 B (0%)
build/edit-post/style-rtl.css 6.33 kB +23 B (0%)
build/edit-post/style.css 6.31 kB +24 B (0%)
build/edit-site/index.js 21.2 kB +36 B (0%)
build/edit-site/style-rtl.css 3.81 kB +47 B (1%)
build/edit-site/style.css 3.82 kB +46 B (1%)
build/edit-widgets/index.js 21.5 kB +43 B (0%)
build/edit-widgets/style-rtl.css 3 kB +25 B (0%)
build/edit-widgets/style.css 3 kB +25 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.54 kB 0 B
build/api-fetch/index.js 3.35 kB 0 B
build/autop/index.js 2.72 kB 0 B
build/blob/index.js 668 B 0 B
build/block-directory/index.js 8.6 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/style-rtl.css 10.9 kB 0 B
build/block-editor/style.css 10.9 kB 0 B
build/block-library/editor-rtl.css 8.65 kB 0 B
build/block-library/editor.css 8.65 kB 0 B
build/block-library/style-rtl.css 7.71 kB 0 B
build/block-library/style.css 7.71 kB 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-default-parser/index.js 1.78 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 47.6 kB 0 B
build/components/style-rtl.css 15.4 kB 0 B
build/components/style.css 15.4 kB 0 B
build/compose/index.js 9.63 kB 0 B
build/core-data/index.js 12.1 kB 0 B
build/data-controls/index.js 684 B 0 B
build/data/index.js 8.63 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/dom/index.js 4.43 kB 0 B
build/edit-navigation/index.js 10.6 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/editor/editor-styles-rtl.css 480 B 0 B
build/editor/editor-styles.css 482 B 0 B
build/editor/index.js 42.5 kB 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.84 kB 0 B
build/element/index.js 4.45 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.49 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 1.74 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.54 kB 0 B
build/is-shallow-equal/index.js 709 B 0 B
build/keyboard-shortcuts/index.js 2.39 kB 0 B
build/keycodes/index.js 1.85 kB 0 B
build/list-reusable-blocks/index.js 3.02 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.12 kB 0 B
build/notices/index.js 1.69 kB 0 B
build/nux/index.js 3.27 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.44 kB 0 B
build/primitives/index.js 1.34 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/reusable-blocks/index.js 3.04 kB 0 B
build/rich-text/index.js 13 kB 0 B
build/server-side-render/index.js 2.6 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.24 kB 0 B
build/url/index.js 4.07 kB 0 B
build/viewport/index.js 1.75 kB 0 B
build/warning/index.js 1.13 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@jeyip jeyip force-pushed the update/navigation-ui-placement branch Oct 7, 2020
@jeyip jeyip marked this pull request as ready for review Oct 7, 2020
@jeyip jeyip force-pushed the update/navigation-ui-placement branch 3 times, most recently to 390e69f Oct 7, 2020
) }
<div className="interface-interface-skeleton__body">
{ !! leftSidebar && (
<div className="interface-interface-skeleton__layout">

This comment has been minimized.

@jeyip

jeyip Oct 8, 2020
Author Contributor

Note:
Previously, the navigation panel and navigation toggle lived within skeleton__body and skeleton__header, respectively. In order to address unexpected keyboard focus order between the nav toggle and nav panel, we create a new element inside of interface-skeleton called skeleton__navigation-sidebar.

To account for the layout changes of introducing a new element, we add two wrapper classes: skeleton__site and skeleton__content. Both ensure that the skeleton__header and skeleton__body shrink their children correctly when the navigation sidebar is open.

@@ -6,6 +6,8 @@
background: $gray-900;
border-radius: 0;
display: flex;
position: absolute;

This comment has been minimized.

@jeyip

jeyip Oct 8, 2020
Author Contributor

Note:
When the navigation sidebar is closed, the skeleton body (i.e. the block editor) no longer spans the entire width of the viewport. The sidebar (and toggle) occupy space at the left edge of the screen. To address this, we position the navigation toggle absolutely when the sidebar is closed.

@jeyip jeyip requested a review from shaunandrews Oct 8, 2020
@vindl vindl requested a review from mattwiebe Oct 8, 2020
@vindl vindl added this to Needs review in Full site editing Oct 8, 2020
onClick={ onNavigationToggle }
/>
{ content === 'navigation' && isOpen && <NavigationPanel /> }
</>

This comment has been minimized.

@Copons

Copons Oct 8, 2020
Contributor

Should we keep the MainDashboardButton.Slot removed from packages/edit-site/src/components/header/index.js?

This comment has been minimized.

@vindl

vindl Oct 8, 2020
Member

I think it should now wrap Back to Dashboard button, instead of the main one that toggles the sidebar. That's what it does in post editor too.

@Copons
Copy link
Contributor

@Copons Copons commented Oct 8, 2020

The behaviour here feels good to me, and the keyboard navigation is exactly as I would expect.

As mentioned elsewhere, I'd even go as far as removing the auto-focus on the first button inside the navigation (Back to Dashboard) on sidebar toggle, since now it's only as far as a simple tab press.
I'd defer this decision to a11y, though.


Most obvious change required: replace all the new z-index values with the z-index mixin, as mentioned in an inline comment.


About the InterfaceSkeleton change.

I don't see any obvious regressions, but I'm wondering if there's a way to tidy it up a little bit.
(Note that I haven't tested my propositions, so I'm not certain they would work 🙂)

  • Is the interface-interface-skeleton__layout wrapper essential?
    Couldn't we just use the root interface-interface-skeleton as container?
    Off the top of my head, the reason for __layout is so that the interface-interface-skeleton__footer is not affected by the navigation sidebar sliding in.
    What if, instead, the sidebar "moved" the footer as well, exactly like it moves header and content?
    (Note that this is possibly kinda awkward, considering that status bars are usually full-width unaffected by any other UI element of the window.)

  • How do you feel about interface-interface-skeleton__editor instead of interface-interface-skeleton__site?

  • Is "navigation sidebar" a good and descriptive name for the new skeleton element?
    I wonder if "navigation" is too semantically specific, whereas I guess we should probably just convey an "interface" meaning (e.g. just "sidebar").
    For example, "Drawer" sounds like a good and descriptive name to me: it's established as a UI element (e.g. Google's Material), and it conveys a "sliding" movement, different from the other sidebars, who just simply appear.

@jeyip
Copy link
Contributor Author

@jeyip jeyip commented Oct 9, 2020

Is the interface-interface-skeleton__layout wrapper essential?

Great catch! You were spot on about why I initially implemented skeleton-layout, but it turns out that we can remove the layout wrapper while still preserving current behavior. skeleton-footer has position fixed, which always attaches it to the bottom of the screen 🙂

How do you feel about interface-interface-skeleton__editor instead of interface-interface-skeleton__site?

editor is more semantically specific but it conveys a lot more meaning. I'm on board.

Is "navigation sidebar" a good and descriptive name for the new skeleton element?
I wonder if "navigation" is too semantically specific, whereas I guess we should probably just convey an "interface" meaning (e.g. just "sidebar"). For example, "Drawer" sounds like a good and descriptive name to me: it's established as a UI element (e.g. Google's Material), and it conveys a "sliding" movement, different from the other sidebars, who just simply appear.

Agreed. I'll give this more thought and circle back tomorrow. For now, I'll use drawer instead of navigation-sidebar.

Copy link
Contributor

@Copons Copons left a comment

This is looking good to me!

I've left a few comments: all minor stuff and discussion points, possibly to keep in mind for follow ups!

I'd love to have a few more 👀 on the interface changes, as this is the first time I've dabbled with it.

isNavigationOpen
}
onNavigationToggle={ () =>
toggleLeftSidebarContent(

This comment has been minimized.

@Copons

Copons Oct 9, 2020
Contributor

(More of a pondering than a request)

Given that now the navigation sidebar is completely separated from the left sidebar, I think they should be handled by different states (e.g. setLeftSidebar and setNavigationSidebar).

With different states we could even have both sidebar visible at the same time.
I don't know if it's something we want, though, as we might end up with 3 sidebars open at the same time, which feels very cluttered to me.

Either way, we can make navigation and left sidebars "interdependent": when you open one, automatically close the other.

This comment has been minimized.

@noahtallen

noahtallen Oct 10, 2020
Member

I wanted to put the nav state into redux so I could use it in a random component, so i tried this out here: #26003

@@ -1,7 +1,6 @@
.edit-site-navigation-panel {
animation: edit-site-navigation-panel__slide-in 0.1s linear;
height: 100%;

This comment has been minimized.

@Copons

Copons Oct 9, 2020
Contributor

(Not caused by this PR, but it's more a mental note to address it at some point)

The panel is 100% height, but in fact it should be slightly shorter: it's pushed down by the header (60px + 1px of border), and it's supposed to end above the footer (25px, only on "> mobile").

I guess we could remove those 86px from the height with calc() or as a bottom padding.

Somewhat related: the Navigation component hides both overflows, while it only really needs to hide overflow-x.
Hiding overflow-y means that if the menu is taller than the screen, it gets cut off.

packages/edit-site/src/components/editor/index.js Outdated Show resolved Hide resolved
@noahtallen noahtallen mentioned this pull request Oct 10, 2020
6 tasks done
@Copons Copons force-pushed the update/navigation-ui-placement branch to 4a2937a Oct 15, 2020
@Copons
Copy link
Contributor

@Copons Copons commented Oct 15, 2020

Sorry! Those two commits are meant to be committed to a different branch 😬

No worries! Rebased the PR and dropped the rogue commits.

@Copons Copons merged commit cffac59 into master Oct 15, 2020
15 checks passed
15 checks passed
@github-actions
Cancel Previous Runs Cancel Previous Runs
Details
@github-actions
Check Check
Details
@github-actions
build
Details
@github-actions
Admin - 1
Details
@github-actions
Compare performance with master
Details
@github-actions
pull-request-automation
Details
@github-actions
test (gutenberg-editor-gallery) test (gutenberg-editor-gallery)
Details
@github-actions
test (gutenberg-editor-gallery)
Details
@github-actions
JavaScript
Details
@github-actions
Admin - 2
Details
@github-actions
Admin - 3
Details
@github-actions
Mobile
Details
@github-actions
Admin - 4
Details
Full site editing automation moved this from Needs review to Done Oct 15, 2020
@Copons Copons deleted the update/navigation-ui-placement branch Oct 15, 2020
@github-actions github-actions bot added this to the Gutenberg 9.2 milestone Oct 15, 2020
@jeyip
Copy link
Contributor Author

@jeyip jeyip commented Oct 19, 2020

@Copons Thanks for merging this! 🙏

@@ -56,6 +56,7 @@ $mobile-header-toolbar-height: 44px;
$mobile-floating-toolbar-height: 44px;
$mobile-floating-toolbar-margin: 8px;
$mobile-color-swatch: 48px;
$header-toolbar-min-width: 335px;

This comment has been minimized.

@jasmussen

jasmussen Oct 26, 2020
Contributor

@jeyip I know this value is iPhone friendly, but it doesn't appear to work as intended as the mobile experience is otherwise broken. The variable is also used only in this PR and no-where else. I'd recommend not adding this variable, and instead either use $break-mobile from _breakpoints.scss so as to avoid fragmenting the responsive dev.

We also have some good mixins that help mobile dev, such as @include break-small() { ... } to abstact and keep things in sync.

This comment has been minimized.

@jeyip

jeyip Oct 26, 2020
Author Contributor

The 335px was meant to ensure a certain width for the toolbar on either side of the header used here and here. The min width prevented the left and right toolbars from collapsing as the browser viewport was shrunk horizontally. Giving this more thought, it should absolutely be a desktop specific affordance. I'm happy to open another PR incorporating the break point mixins.

Screen Shot 2020-10-26 at 3 21 32 PM

I'd recommend not adding this variable, and instead either use $break-mobile from _breakpoints.scss so as to avoid fragmenting the responsive dev.

I'm not quite sure I'm tracking here. I think the name of the variable may be misleading, because it sounds like we see the 335px as an iphone friendly breakpoint?

This comment has been minimized.

@jasmussen

jasmussen Oct 27, 2020
Contributor

Ah! Thank you for the explanation. I initially pondered where those 335px came from, because it seems a relatively arbitrary number given the base8 grid most of the UI uses. I then thought — maybe it's that somewhat odd iphone resolution which I remembered as 335px (iPhone 6: 750 x 1334, which makes it 375 points horizontally) but as you can see, I was wrong.

With your explanation, though, I think a different approach is needed for min-width. Longer term I think we need to stack the toolbar if there isn't space, but nearer term I think smaller steps can be taken.

I'm happy to open another PR incorporating the break point mixins.

#26021 does that, and but also hides some buttons, and minimizes labels, as the viewport approaches mobile breakpoints. It's only a first step, and more are needed, but it's a good step. It's currently blocked on the white screen as shown in the intro of the PR, which happens because the left sidebar is always output, regardless of open or not. I could use help with that if you have bandwidth!

I'm not quite sure I'm tracking here. I think the name of the variable may be misleading, because it sounds like we see the 335px as an iphone friendly breakpoint?

To be specific, we should only be creating new variables in the _variables.scss file if they are meant to be used widely and in multiple places. If it's just for the site editor as is currently the case, I'd just type the content of the variable directly where needed, or just register the variable directly in those files.

I'd look at finding a different approach than the min-width, though (not urgently) it seems a half-step towards solving a problem that needs a more foundational mobile improvement. The work could probably coincide with enforcing of the stacking top toolbar, so we fix this:

Screenshot 2020-10-27 at 09 55 55

I know it's beta! I know there's a lot of work to be done. I'm just:

  • excited about the site editor
  • of the belief that if we test mobile in every PR, even if it's not superb, we minimize future headaches

This comment has been minimized.

@jeyip

jeyip Oct 27, 2020
Author Contributor

I added a commit and a comment to #26021 that potentially address the issues you bring up here.

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Oct 26, 2020

This PR appears to consider mobile (specificaly the iPhone based on the 335px variable introduced), but the mobile experience remains broken, so I'm curious how this was tested for mobile. For me, the site editor is just a white screen on mobile, something which #26021 fixes, but even after that fix, the 335px variable appears to not really address any mobile issues.

I really appreciate all the work you're doing on this, and I know it's super early to optimize for a breakpoint that is likely going to be rarely used for building templates. However this will nevertheless need to be considered at some point, and the sooner we start testing it, the less technical debt we will have to revisit and fix.

Most of the time it's it's enough to wrap desktop-specific affordances in a @include break-small() { ... } clause.

@jeyip
Copy link
Contributor Author

@jeyip jeyip commented Oct 26, 2020

This PR appears to consider mobile (specificaly the iPhone based on the 335px variable introduced), but the mobile experience remains broken, so I'm curious how this was tested for mobile.

Thanks for your thoughts @jasmussen. They're much appreciated.

To clarify, although the PR appears to consider mobile (like the 335px variable), I didn't explicitly take mobile screens into account, which admittedly might be an oversight. I only ensured that the desktop behaved responsively up to the point where the tablet / mobile break-points take over. I've seen the mobile white screen for a while in site editor development, which is part of the reason why I didn't test behavior at smaller screen widths. I should've, however, been more proactive about calling out the unexpected behavior that you're addressing in #26021.

I really appreciate all the work you're doing on this, and I know it's super early to optimize for a breakpoint that is likely going to be rarely used for building templates. However this will nevertheless need to be considered at some point, and the sooner we start testing it, the less technical debt we will have to revisit and fix.

I think these are very valid points, especially if we plan on supporting mobile site editing in the future. It's tough developing for a mobile experience without an idea of what it will look like, but I agree that we can circumvent a lot of issues with desktop-specific affordances wrapped in breakpoint mixins.

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Oct 27, 2020

It's tough developing for a mobile experience without an idea of what it will look like, but I agree that we can circumvent a lot of issues with desktop-specific affordances wrapped in breakpoint mixins.

Absolutely.

And in absence of full knowledge of that, I'd just test site editor PRs against a viewport that's <600px wide and see how broken it is. As we move forward, we can then raise the bar for what brokenness we're willing to accept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment