Expand EuiFlyout usage to help EuiCollapsibleNav#4713
Expand EuiFlyout usage to help EuiCollapsibleNav#4713cchaos merged 41 commits intoelastic:masterfrom
Conversation
Also does a better job with mobile sizing and not just overtaking the whole screen all the time
…‘outside’ but default in EuiCollabsibleNav
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
push type and side prop. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
…ate/collapsible-nav
Update/collapsible nav - forwardRef
…e-nav # Conflicts: # CHANGELOG.md # src/components/collapsible_nav/__snapshots__/collapsible_nav.test.tsx.snap # src/components/flyout/__snapshots__/flyout.test.tsx.snap
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
src/components/flyout/flyout.tsx
Outdated
| * Defaults to `dialog` which is best for most cases of the flyout. | ||
| * Otherwise pass in your own, aria-role, or `none` to remove it and use the semantic `as` element instead | ||
| */ | ||
| role?: 'none' | string; |
There was a problem hiding this comment.
What do you think about dropping none and relying on role={undefined} to unset instead?
There was a problem hiding this comment.
Yeah I had tried that before and was getting a11y errors, and I just tried again by just setting role?: string but passing role={undefined} seems to completely ignore the undefined and always keep the default 'dialog'. I did try with null, which works but that means just changing this to role?: null | string; but undefined still won't work.
Should I go with null?
There was a problem hiding this comment.
Ack, that's right, because the default value is applied when a value is undefined. I think null is a bit cleaner than 'none', but I'm good either way
elizabetdev
left a comment
There was a problem hiding this comment.
Tested in Chrome, Firefox, Safari and Edge. LGTM! 🎉
I just have a few suggestions.
| props: { EuiCollapsibleNav }, | ||
| demo: <CollapsibleNav />, | ||
| snippet: `<EuiCollapsibleNav | ||
| ownFocus={false} |
There was a problem hiding this comment.
Is there any reason we want the snippet to have ownFocus={false}?
There was a problem hiding this comment.
Ah yeah, so in Kibana we're going to use this setting on the global nav and went back and forth whether our docs should have it off by default too, then I think I forgot to update the snippet. Good catch.
chandlerprall
left a comment
There was a problem hiding this comment.
Changes LGTM! Lots of goods things here
thompsongl
left a comment
There was a problem hiding this comment.
I will likely not have time to review this today, but I'm good merging with the current approvals in place.
chandlerprall
left a comment
There was a problem hiding this comment.
null role change LGTM
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
This PR mainly pushes a bunch of custom props implemented for EuiCollapsibleNav back up to EuiFlyout so that EuiCollapsibleNav can just extend EuiFlyout and EuiFlyout gets more customization options.
👉 EuiFlyout new/adjusted props
asThis helps the EuiCollapsibleNav or any other consumption to pass
navas an element directly.roleThis also helps the EuiCollapsibleNav or any other consumption to change the aria-role type to fit their needs.
sizenow accepts any viable CSSwidthvalueAllows for real customization of the actual rendered flyout width instead of relying on max-width or overrides.
closeButtonPropsGood for extending/changing things like
data-test-subjor adding aclassName.closeButtonPositionThis was added to push up EuiCollapsibleNav's custom implementation of a solid close button that floats outside of the flyout, instead of within. Purposefully, there was no documentation added around this as we want to try to stay consistent for default EuiFlyout types.
outsideClickClosesAlso another request of the EuiCollapsibleNav is to allow a version where there's no overlay mask obscuring the content beneath, but we still want it to close automatically when starting to interact with the page content.
Video
Screen.Recording.2021-04-19.at.04.26.08.PM.mp4
sideThis removed the duplication of the CSS styles via the
euiFlyout()Sass mixin in EuiCollapsibleNav and just added a quick manipulation of the position CSS for the flyout itself. Again, purposefully left this prop out of the docs examples as we want the default to always beright.typeThis one might be controversial. But, we have custom implementations like this in Kibana that would be good to maintain at the EUI level. It helps EuiCollapsibleNav maintain the
dockedstatus and how the body accommodates for it with padding.pushMinBreakpoint👉 EuiCollapsibleNav now extends EuiFlyout
The props list has been shortened and instead extends all the same props as EuiFlyout (with a few exceptions like
typebecause it manages this withisDocked).🔔 Breaking changes
EuiFlyout now defaults to
ownFocus = trueThis means that any default implementations of EuiFlyout with display the overlay mask. This is inherently good for accessibility and the proper way to display EuiFlyouts. The version without the overlay mask is the lesser common use or should be less common.
To compensate: If you need users to maintain the ability to interact with page contents while the flyout is open, set
ownFocus={false}. Otherwise, the overlay mask is appropriate.EuiFlyout gets wrapped in an EuiPortal when
ownFocus = trueBecause z-indexes are terrible and overlay masks are always in a portal, but the flyout itself was not, we were using z-indexes to position these layers. But this broke as soon as
position: relativewas added to any element wrapping the EuiFlyout. So now we just append the flyout to the document body within the overlay mask if the overlay mask exists (whenownFocus = true).To compensate: There shouldn't need to be anything to do here unless there's a specific reason you need the flyout to exist in the nested dom exactly where it is placed in the code.
EuiCollapsibleNav now manages width via prop instead of CSS
Since the component extends EuiFlyout which accepts a number or string value via the
sizeprop, the Sass variable$euiCollapsibleNavWidthhas been removed in favor of this React prop. Though, the default width is still the same320px.To compensate: Delete any usages of
$euiCollapsibleNavWidthand apply your custom width as thesizeprop.EuiOverlayMask no longer uses z-index alone for determining position
belowheaderThe z-index now actually matches that of the EuiHeader, but since it's in a portal (appended to the dom) it will alway be "above" to ensure it sits above any non-fixed headers. So in order to make it appear below the header, it now uses the
topvalue to offset it's position. This is added in theeuiHeaderAffordForFixed()Sass mixin.To compensate: As long as you are still using the
euiHeaderAffordForFixed()Sass mixin for other offsets based on fixed headers, there's nothing to do. Otherwise, you will have to afford for this manually.Other
Added a
isWithinMinBreakpoint()breakpoint service to help find when the browser width is actually above the breakpoint passed.Checklist