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

Fix Dropdown/DropdownMenu toggle closing in all UAs #31170

Merged
merged 4 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
>
<div
className="components-dropdown components-circular-option-picker__dropdown-link-action"
tabIndex="-1"
>
<button
aria-describedby={null}
Expand Down
3 changes: 0 additions & 3 deletions packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ export default function TemplatePartEdit( {
<ToolbarButton
aria-expanded={ isOpen }
onClick={ onToggle }
// Disable when open to prevent odd FireFox bug causing reopening.
// As noted in https://github.com/WordPress/gutenberg/pull/24990#issuecomment-689094119 .
disabled={ isOpen }
>
{ __( 'Replace' ) }
</ToolbarButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ exports[`ColorPalette Dropdown should render it correctly 1`] = `
>
<div
className="components-dropdown components-circular-option-picker__dropdown-link-action"
tabIndex="-1"
>
<ForwardRef(Button)
aria-expanded={false}
Expand Down Expand Up @@ -545,6 +546,7 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
>
<div
className="components-dropdown components-circular-option-picker__dropdown-link-action"
tabIndex="-1"
>
<ForwardRef(Button)
aria-expanded={false}
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export default function Dropdown( {
<div
className={ classnames( 'components-dropdown', className ) }
ref={ containerRef }
// Some UAs focus the closest focusable parent when the toggle is
// clicked. Making this div focusable ensures such UAs will focus
// it and `closeIfFocusOutside` can tell if the toggle was clicked.
tabIndex="-1"
stokesman marked this conversation as resolved.
Show resolved Hide resolved
>
{ renderToggle( args ) }
{ isOpen && (
Expand Down