Skip to content

Commit

Permalink
DropdownMenu V2: add CSS subgrid fallback styles (#57327)
Browse files Browse the repository at this point in the history
* DropdownMenu V2: add fallback styles for when subgrid is not supported

* CHANGELOG

* Simplify solution

* Extract common grid template cols

* Undo indentation change

* Typo
  • Loading branch information
ciampo authored Dec 22, 2023
1 parent ebb171b commit ea21160
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Bug Fix

- `DropdownMenu V2 `: better fallback on browsers that don't support CSS subgrid([#57327](https://github.com/WordPress/gutenberg/pull/57327)).
- `FontSizePicker`: Use Button API for keeping focus on reset ([#57221](https://github.com/WordPress/gutenberg/pull/57221)).
- `FontSizePicker`: Fix Reset button focus loss ([#57196](https://github.com/WordPress/gutenberg/pull/57196)).
- `PaletteEdit`: Consider digits when generating kebab-cased slug ([#56713](https://github.com/WordPress/gutenberg/pull/56713)).
Expand Down
19 changes: 13 additions & 6 deletions packages/components/src/dropdown-menu-v2/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const TOOLBAR_VARIANT_BORDER_COLOR = COLORS.gray[ '900' ];
const DEFAULT_BOX_SHADOW = `0 0 0 ${ CONFIG.borderWidth } ${ DEFAULT_BORDER_COLOR }, ${ CONFIG.popoverShadow }`;
const TOOLBAR_VARIANT_BOX_SHADOW = `0 0 0 ${ CONFIG.borderWidth } ${ TOOLBAR_VARIANT_BORDER_COLOR }`;

const GRID_TEMPLATE_COLS = 'minmax( 0, max-content ) 1fr';

const slideUpAndFade = keyframes( {
'0%': {
opacity: 0,
Expand Down Expand Up @@ -76,7 +78,7 @@ export const DropdownMenu = styled( Ariakit.Menu )<
z-index: 1000000;
display: grid;
grid-template-columns: minmax( 0, max-content ) 1fr;
grid-template-columns: ${ GRID_TEMPLATE_COLS };
grid-template-rows: auto;
box-sizing: border-box;
Expand Down Expand Up @@ -130,14 +132,19 @@ const baseItem = css`
/* Occupy the width of all grid columns (ie. full width) */
grid-column: 1 / -1;
/*
* Define a grid layout which inherits the same columns configuration
* from the parent layout (ie. subgrid).
*/
display: grid;
grid-template-columns: subgrid;
grid-template-columns: ${ GRID_TEMPLATE_COLS };
align-items: center;
@supports ( grid-template-columns: subgrid ) {
/*
* Define a grid layout which inherits the same columns configuration
* from the parent layout (ie. subgrid). This allows the menu
* to synchronize the indentation of all its items.
*/
grid-template-columns: subgrid;
}
font-size: ${ font( 'default.fontSize' ) };
font-family: inherit;
font-weight: normal;
Expand Down

1 comment on commit ea21160

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in ea21160.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7299725575
📝 Reported issues:

Please sign in to comment.