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

[EuiCollapsibleNavBeta] Final collapsed/docked icon & popover behavior #7034

Merged
merged 14 commits into from
Aug 7, 2023

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Aug 4, 2023

Summary

This PR implements the final collapsed/docked behavior on desktop/wider screens:

  • Each top-level navigation item should always have a tooltip
  • Navigation items with sub-items (would render an accordion normally) will instead render a popover
  • Navigation items with no sub-items will render a button/link as they would normally. Unlike non-collapsed items, a static <span> will never be rendered, as tooltips require focusable anchors for accessibility.

As always, there's a lot going on here and some commits specifically dedicated to cleaning up some things I missed in the previous PR, so follow along by commit!

QA

  • gh pr checkout 7034
  • yarn storybook

EuiCollapsedNavItem testing

  • Go to http://localhost:6006/?path=/story/euicollapsednavitem--playground
  • Play with the icon control and confirm it can be customized
  • Clear the icon control and confirm it falls back to a 'boxes' icon
  • Hover over the popover and confirm it renders a tooltip with the item title
  • Open the popover confirm the title is also displayed as a popover title, and can be a link
  • Clear the href control and confirm the popover title is no longer a link / is a static span
  • Edit the title control to a really long string and confirm the popover title truncates
  • Clear the items object of all keys and confirm the popover disappears, and the icon (if empty) now falls back to a link icon
  • Toggle the isSelected control and confirm a background color is applied

EuiCollapsibleNavBeta testing

  • Go to http://localhost:6006/?path=/story/euicollapsiblenavbeta--kibana-example
  • Ensure you're on desktop mode, then click the collapse button
  • Confirm all top-level collapse to their icons and render the expected tooltips/popovers
  • Confirm that on popover open, the tooltip disappears
  • Regression testing
    • Open the Security item and confirm the nested accordion items work as expected
    • On mobile screens, confirm the collapsible nav still retains its flyout / full-width behavior

General checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Added or updated jest and cypress tests
  • [ ] Checked for accessibility including keyboard-only and screenreader modes While this is an "okay" experience currently, it could certainly be better. I plan on doing a separate a11y polish pass PR after this, and looping in Trevor for his expertise.

Skipping due to beta component status:
- [ ] A changelog entry exists and is marked appropriately
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Props have proper autodocs (using @default if default values are missing) and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for any docs examples
- [ ] Updated the Figma library counterpart

cee-chen added 10 commits August 3, 2023 21:37
- this isn't required by this PR, I just noticed it while working and wanted to clean up the className output of various sub-components to match their actual usage/component names
- `linkProps` should only be spread to actual EuiLink components, and not to the `span`

- in reality, I'm not super sure how much of a difference this will make to consumers, but the upcoming collapsed nav item work will also behave this way and it's better to be consistent
- this may seem silly right now for just `EuiCollapsibleNavButton`, but it'll be needed by EuiCollapsibleNavBeta's children and grandchildren which we can't simply pass props directly to
- will be used by all top level items in collapsed/docked desktop state
- Similar to how `EuiCollapsibleNavAccordion` dogfoods `EuiCollapsibleNavLink`, this component dogfods `EuiCollapsedNavButton`
 - which is a light wrapper similar to `EuiCollapsibleNavItemDisplay` that determines whether to render a nav component with or without items
- from both the nav toggle button and all docked button icons

+ fix missing `className`/`css` merging & tests on `EuiCollapsibleNavButton` - in theory EUI's the only ones using the component, but might as well make it flexible
- for mouse users, the cursor is still hovered over the button icon even when the popover is open, so the tooltip overlays on the popover title when it shouldn't

- for keyboard users, this isn't an issue
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_7034_buildkite/

- scrollbars that take up width (e.g. windows, mac setting) will cut too much into icon visibility otherwise. This CSS visually hides the scrollbars for all supported browsers while still allowing the containers to remain scrollable
@cee-chen cee-chen force-pushed the collapsible-nav-beta branch from 113b497 to f9838a3 Compare August 4, 2023 06:19
@cee-chen cee-chen requested a review from breehall August 4, 2023 06:38
Comment on lines +29 to +33
euiCollapsibleNavButton: css`
&.euiButtonIcon:hover {
transform: none;
}
`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit (965b476) was a request from Marcialis. I missed implementing it as part of the previous PR so figured I'd grab it in here.

The &.euiButtonIcon specificity is unfortunately necessary to override EuiButtonicon's existing hover CSS.

Comment on lines +48 to +52
// If the item has a popover and the popover is open, we don't want the
// tooltip to appear if so - the popover already renders the item title
hidden: css`
display: none;
`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this extra logic/CSS, you get this silliness:

tooltip

You can still overlap the tooltips of other nav items onto open popovers, but at least that doesn't repeat information.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

Comment on lines +18 to +20
/* This extra padding is needed for EuiPopovers to have enough
space to render with the right anchorPosition */
${logicalCSS('padding-bottom', euiTheme.size.xs)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise we get this:

When we want this:

Comment on lines 41 to 52
isDesktopCollapsed: css`
/* Hide the scrollbar for docked mode (while still keeping the nav scrollable)
Otherwise if scrollbars are visible, button icon visibility suffers */
&,
.euiFlyoutBody__overflow {
scrollbar-width: none; /* Firefox */

&::-webkit-scrollbar {
display: none; /* Chrome, Edge, & Safari */
}
}
`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this conditional CSS, you get this horrible shenanigans:

Which, I guarantee, will unfortunately only look worse on Windows 😬

I'm opting to only set this on for the docked/icon mode, as the normal nav items display will adjust to accommodate a scrollbar width.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note - I just pushed up a naming refactor (a582ddc), but that should be my last set of changes / this PR is all ready to review after that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to note - I know this test (and dev tools) triggers this warning repeatedly:

I'm opting to skip it for now and tackle it in a separate accessibility PR/pass. The main reason it's actually not a major a11y issue is because of the wrapping EuiToolTip, which sets an aria-describedby on the button icon.

So the title will still get read out, albeit less quickly than an aria-label would. But if I try to set an aria-label now, what happens is the title then gets repeated twice due to the tooltip describedby, which TBH feels worse. So I'd rather try to fix the issue more completely, hence the separate follow-up work.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_7034/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_7034_buildkite/

@cee-chen cee-chen changed the title [EuiCollapsibleNavBeta] Final collapsed/dock icon/popover behavior [EuiCollapsibleNavBeta] Final collapsed/docked icon & popover behavior Aug 4, 2023
- I totally missed this in the Figma mocks 🥲
- instead of using `small`/`mobile`/`desktop`, use `push` vs `overlay` naming instead, which better describes what state the flyout is in

- this matches the paradigm we want of container vs media queries - we should be describing how the *flyout* is behaving, not what size we think the user's screen is
@cee-chen cee-chen force-pushed the collapsible-nav-beta branch from 81f63ba to a582ddc Compare August 4, 2023 18:27
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_7034_buildkite/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_7034/

Copy link
Contributor

@breehall breehall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good overall. I spent a good amount of time with the collapse functionality and verifying across different screen sizes. The ability to navigate when the menu is collapsed (on desktop) is a nice touch!

[Consideration] I also spent some time with keyboard navigation. I know another PR for accessibility is coming down the line, but wanted to throw in this note. When the menu is collapsed and you're using the keyboard to navigate to the first item in the menu, it takes three tab pressed to land there. I don't think this is the same as the tabbing issue we identified in the last PR because there are no children between the collapse button and the home item.

image

[Change request] It looks like the arrow states for the accordions are backwards. When the parent is collapsed, I believe the arrow should point down. When the parent is open, the parent should point up. I double checked with this with the Figma spec. I'm not sure how I missed that before, sorry about that!

image

Comment on lines +95 to +96
const [isOverlay, setIsOverlay] = useState(false);
const [isOverlayFullWidth, setIsOverlayFullWidth] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change! It's very intuitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Music to my ears!! 😁

Comment on lines +27 to +30
.euiFlyoutBody {
${logicalCSS('min-height', '50%')}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on this. I toyed around by opening all of the toggles between the flyout body and footer. Hopefully no one would do this, but this is nice just in case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, I remembered that one issue/bug report we got previously and tried to get ahead of it! :)

Comment on lines +48 to +52
// If the item has a popover and the popover is open, we don't want the
// tooltip to appear if so - the popover already renders the item title
hidden: css`
display: none;
`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

@cee-chen
Copy link
Contributor Author

cee-chen commented Aug 4, 2023

[Change request] It looks like the arrow states for the accordions are backwards.

🤦 You're totally right, thank you so much for catching that! 2a1ec67

@cee-chen
Copy link
Contributor Author

cee-chen commented Aug 4, 2023

[Consideration] I also spent some time with keyboard navigation. I know another PR for accessibility is coming down the line, but wanted to throw in this note. When the menu is collapsed and you're using the keyboard to navigate to the first item in the menu, it takes three tab pressed to land there. I don't think this is the same as the tabbing issue we identified in the last PR because there are no children between the collapse button and the home item.

Yep, great catch on this, I noticed the same thing. This behavior is a factor of several issues: Push flyouts in general have odd accessibility compared to non-push flyouts (see #6576), and also the euiFlyoutBody__overflow has a non-configurable tabIndex={0}. So the extra tab stops are being caused the flyout itself (which can be resolved by auto-focusing the flyout on open state, which all push flyouts should do), and the scrolling region needs to be able to intelligently detect whether or not it needs a tabIndex={0} instead of just setting one by default.

All of the above are mediumly complex issues to resolve that I don't want to hold up Kibana's work for, since we can continue to work on them in the background and a11y fixes should Just Work later. 🤞

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_7034_buildkite/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_7034/

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Copy link
Contributor

@breehall breehall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing my questions and flipping the accordion arrow!

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

Successfully merging this pull request may close these issues.

Updates to navigation components in support of Kibana nav redesign
4 participants