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

Snackbar: re-position snackbar above modals #54153

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 2 additions & 2 deletions packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ $z-layers: (
// Above the block list and the header.
".block-editor-block-popover": 31,

// Show snackbars above everything (similar to popovers)
".components-snackbar-list": 100000,
// Show snackbars above everything, including modals (similar to popovers)
".components-snackbar-list": 100001,

// Show modal under the wp-admin menus and the popover
".components-modal__screen-overlay": 100000,
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bug Fix

- `PaletteEdit`: Fix padding in RTL languages ([#54034](https://github.com/WordPress/gutenberg/pull/54034)).
- `Snackbar`: Re-position Snackbar above Modals ([#54153](https://github.com/WordPress/gutenberg/pull/54153)).

## 25.7.0 (2023-08-31)

Expand Down
7 changes: 4 additions & 3 deletions packages/components/src/snackbar/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useReducedMotion } from '@wordpress/compose';
import { useRef } from '@wordpress/element';
import { createPortal, useRef } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -72,7 +72,7 @@ export function SnackbarList( {
const removeNotice =
( notice: SnackbarListProps[ 'notices' ][ number ] ) => () =>
onRemove?.( notice.id );
return (
return createPortal(
<div className={ className } tabIndex={ -1 } ref={ listRef }>
{ children }
<AnimatePresence>
Expand Down Expand Up @@ -103,7 +103,8 @@ export function SnackbarList( {
);
} ) }
</AnimatePresence>
</div>
</div>,
document.body
);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/snackbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@

.components-snackbar-list {
position: absolute;
bottom: $grid-unit-50;
left: $grid-unit-20;
z-index: z-index(".components-snackbar-list");
width: 100%;
box-sizing: border-box;
Expand Down
Loading