-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Navigation block: use <dialog>
#69720
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
Open
stokesman
wants to merge
24
commits into
trunk
Choose a base branch
from
try/navigation-block-dialog
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3ea96bf
Navigation block: use <dialog>
stokesman f5baf29
Restore `Escape` handling to close sub menus
stokesman 9498f66
Ensure closing logic is applied by listening to dialog `close`
stokesman c4f7c43
Temporarily omit focus trap testing in E2E
stokesman b5dc382
Try fixing color inheritance due to UA styles on <dialog>
stokesman 6046f5c
Avoid closing submenu on hover out if opened by click
stokesman b9a6a53
Use async directive for submenu keydown
stokesman aad3ae3
Use Invoker Commands for dialog
stokesman a693293
Consolidate open/close effectual code
stokesman 8837ba3
Remove tabbing assertions; remove webkit specific test
stokesman ecce206
Revise CSS selector and add no-JS equivalent
stokesman 01643fa
Move aria-label to dialog element
stokesman ef6c7f2
Revise submenu hover conditionals
stokesman f550145
Restore important rules for inheriting colors when overlay is not open
stokesman 370b204
Use `:open` instead of `[open]`
westonruter 74b77a8
Add `:open` selector where it was missing
stokesman 42d6402
Set focus on first link when the nav menu opens
westonruter 966098f
Use [open] selector to support more browsers
stokesman c3c9a37
Fix e2e `overlayMenu` attribute values
stokesman 4fb7c98
Update e2e test to work in webkit
stokesman 2811cc2
Add open/close handlers only if Invoker commands aren’t supported
stokesman 6a086f6
Fix focus return for Escape key presses
stokesman 8188533
Merge branch 'trunk' into try/navigation-block-dialog
stokesman bedfafb
Fixup of merge commit
stokesman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -466,12 +466,14 @@ button.wp-block-navigation-item__content { | |
| } | ||
| } | ||
| .wp-block-navigation__responsive-container { | ||
| display: none; | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| color: inherit; | ||
| background-color: inherit; | ||
| width: auto; | ||
| height: auto; | ||
| max-width: 100%; | ||
| max-height: 100%; | ||
| box-sizing: border-box; | ||
| border: 0; | ||
|
|
||
| // Low specificity so that themes can override. | ||
| & :where(.wp-block-navigation-item a) { | ||
|
|
@@ -486,9 +488,9 @@ button.wp-block-navigation-item__content { | |
| align-items: var(--navigation-layout-align, initial); | ||
| } | ||
|
|
||
| // If the responsive wrapper is present but overlay is not open, | ||
| // overlay styles shouldn't apply. | ||
| &:not(.is-menu-open.is-menu-open) { | ||
| // If the responsive wrapper is present but overlay is not open, overlay colors | ||
| // shouldn't apply and !important is to override color classes or inline styles. | ||
| &:not(.is-menu-open, [open]) { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| color: inherit !important; | ||
| background-color: inherit !important; | ||
| } | ||
|
|
@@ -498,10 +500,9 @@ button.wp-block-navigation-item__content { | |
| // Inherit as much as we can regarding colors, fonts, sizes, | ||
| // but otherwise provide a baseline. | ||
| // In a future version, we can explore more customizability. | ||
| &.is-menu-open { | ||
| display: flex; // Needs to be set to override "none". | ||
| &:is(.is-menu-open, [open]) { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| display: flex; | ||
| flex-direction: column; | ||
| background-color: inherit; | ||
|
|
||
| // Animation. | ||
| @media not (prefers-reduced-motion) { | ||
|
|
@@ -518,9 +519,6 @@ button.wp-block-navigation-item__content { | |
| // Allow modal to scroll. | ||
| overflow: auto; | ||
|
|
||
| // Give it a z-index just higher than the adminbar. | ||
| z-index: 100000; | ||
|
|
||
| .wp-block-navigation__responsive-container-content { | ||
| // Add padding above to accommodate close button. | ||
| padding-top: calc(2rem + #{ $navigation-icon-size }); | ||
|
|
@@ -612,7 +610,7 @@ button.wp-block-navigation-item__content { | |
|
|
||
| @include break-small() { | ||
| &:not(.hidden-by-default) { | ||
| &:not(.is-menu-open) { | ||
| &:not(.is-menu-open, [open]) { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| display: block; | ||
| width: 100%; | ||
| position: relative; | ||
|
|
@@ -625,7 +623,7 @@ button.wp-block-navigation-item__content { | |
| } | ||
| } | ||
|
|
||
| &.is-menu-open { | ||
| &:is(.is-menu-open, [open]) { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| // Override breakpoint-inherited submenu rules. | ||
| .wp-block-navigation__submenu-container.wp-block-navigation__submenu-container.wp-block-navigation__submenu-container.wp-block-navigation__submenu-container { | ||
| left: 0; | ||
|
|
@@ -636,12 +634,12 @@ button.wp-block-navigation-item__content { | |
|
|
||
| // Default menu background and font color. | ||
| .wp-block-navigation:not(.has-background) | ||
| .wp-block-navigation__responsive-container.is-menu-open { | ||
| .wp-block-navigation__responsive-container:is(.is-menu-open, [open]) { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| background-color: #fff; | ||
| } | ||
|
|
||
| .wp-block-navigation:not(.has-text-color) | ||
| .wp-block-navigation__responsive-container.is-menu-open { | ||
| .wp-block-navigation__responsive-container:is(.is-menu-open, [open]) { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| color: #000; | ||
| } | ||
|
|
||
|
|
@@ -712,7 +710,7 @@ button.wp-block-navigation-item__content { | |
| .wp-block-navigation__responsive-close { | ||
| width: 100%; | ||
|
|
||
| .has-modal-open & { | ||
| :is(.is-menu-open, [open]) > & { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| // Try to inherit wide-width when defined, so the X can align to a top-right aligned menu. | ||
| max-width: var(--wp--style--global--wide-size, 100%); | ||
| margin-left: auto; | ||
|
|
@@ -728,28 +726,17 @@ button.wp-block-navigation-item__content { | |
| } | ||
| } | ||
|
|
||
| .is-menu-open .wp-block-navigation__responsive-close, | ||
| .is-menu-open .wp-block-navigation__responsive-dialog, | ||
| .is-menu-open .wp-block-navigation__responsive-container-content { | ||
| .wp-block-navigation__responsive-container:is(.is-menu-open, [open]) /* todo: replace [open] with :open when browser support is widely available. */ | ||
| :is(.wp-block-navigation__responsive-close, .wp-block-navigation__responsive-dialog, .wp-block-navigation__responsive-container-content) { | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| .wp-block-navigation__responsive-dialog { | ||
| position: relative; | ||
| } | ||
|
|
||
| // Adjust open dialog top margin when admin-bar is visible. | ||
| // Needs to be scoped to .is-menu-open, or it will shift the position of any other navigations that may be present. | ||
| .has-modal-open .admin-bar .is-menu-open .wp-block-navigation__responsive-dialog { | ||
| margin-top: $admin-bar-height-big; | ||
|
|
||
| // Handle smaller admin-bar. | ||
| @include break-medium() { | ||
| margin-top: $admin-bar-height; | ||
| } | ||
| } | ||
|
Comment on lines
-741
to
-750
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The overlay ( |
||
|
|
||
| // Prevent scrolling of the parent content when the modal is open. | ||
| html.has-modal-open { | ||
| html.has-modal-open, | ||
| html:has(.wp-block-navigation__responsive-container[open]) { /* todo: replace [open] with :open when browser support is widely available. */ | ||
| overflow: hidden; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
This should also look for other focusable elements to correspond with:
gutenberg/packages/block-library/src/navigation/view.js
Lines 158 to 165 in 42d6402
I only implemented the first of these
focusableSelectorsso far:gutenberg/packages/block-library/src/navigation/view.js
Lines 6 to 14 in 42d6402