-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Editor: Extract snackbars into a separate component #33355
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
Changes from 1 commit
0facff4
501373c
3c480e5
7b885e6
ebd0f5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Editor snackbars are no rendered in the InterfaceSkeleton footer to avoid z-index context issues.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import { filter } from 'lodash'; | ||
|
|
||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { SnackbarList } from '@wordpress/components'; | ||
| import { useSelect, useDispatch } from '@wordpress/data'; | ||
| import { store as noticesStore } from '@wordpress/notices'; | ||
|
|
||
| export default function EditorSnackbars() { | ||
|
Contributor
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. Do you think it should be
Member
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.
Same here 😄 Since "Snackbars" or "Toasts" are notice types themself, I don't think there's a need for the |
||
| const notices = useSelect( | ||
| ( select ) => select( noticesStore ).getNotices(), | ||
| [] | ||
| ); | ||
| const { removeNotice } = useDispatch( noticesStore ); | ||
| const snackbarNotices = filter( notices, { | ||
| type: 'snackbar', | ||
| } ); | ||
|
|
||
| return ( | ||
| <SnackbarList | ||
| notices={ snackbarNotices } | ||
| className="components-editor-notices__snackbar" | ||
| onRemove={ removeNotice } | ||
| /> | ||
| ); | ||
| } | ||
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 think this breaks the UI a bit in "reduced interface mode" (and a couple other modes too). Basically the "footer" is not considered empty any more and an "empty" white area is shown.
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.
Maybe we should move it to the
actionssection?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'm not sure about the implications, it could be worth a try 🤷
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.
Done. Works as expected
actionsarea also hasz-index, so stacking context is good for us. And If I understand correctly other elements rendered here are also popovers.