-
Notifications
You must be signed in to change notification settings - Fork 840
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
Expand EuiFlyout usage to help EuiCollapsibleNav #4713
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
Preview documentation changes for this PR: https://eui.elastic.co/pr_4713/ |
…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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about dropping none
and relying on role={undefined}
to unset instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update to null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in Chrome, Firefox, Safari and Edge. LGTM! 🎉
I just have a few suggestions.
@@ -72,11 +65,14 @@ export const CollapsibleNavExample = { | |||
props: { EuiCollapsibleNav }, | |||
demo: <CollapsibleNav />, | |||
snippet: `<EuiCollapsibleNav | |||
ownFocus={false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason we want the snippet to have ownFocus={false}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM! Lots of goods things here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will likely not have time to review this today, but I'm good merging with the current approvals in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
as
This helps the EuiCollapsibleNav or any other consumption to pass
nav
as an element directly.role
This also helps the EuiCollapsibleNav or any other consumption to change the aria-role type to fit their needs.
size
now accepts any viable CSSwidth
valueAllows for real customization of the actual rendered flyout width instead of relying on max-width or overrides.
closeButtonProps
Good for extending/changing things like
data-test-subj
or adding aclassName
.closeButtonPosition
This 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.
outsideClickCloses
Also 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
side
This 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
.type
This 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
docked
status 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
type
because it manages this withisDocked
).🔔 Breaking changes
EuiFlyout now defaults to
ownFocus = true
This 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 = true
Because 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: relative
was 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
size
prop, the Sass variable$euiCollapsibleNavWidth
has been removed in favor of this React prop. Though, the default width is still the same320px
.To compensate: Delete any usages of
$euiCollapsibleNavWidth
and apply your custom width as thesize
prop.EuiOverlayMask no longer uses z-index alone for determining position
below
headerThe 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
top
value 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