Skip to content

Commit

Permalink
Add id to site save snackbar so only one displayed at a time (#53087)
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz authored Jul 30, 2023
1 parent 0cb48c2 commit 736feac
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/save-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ const PUBLISH_ON_SAVE_ENTITIES = [
];

export default function SaveHub() {
const saveNoticeId = 'site-edit-save-notice';
const { params } = useLocation();

const { __unstableMarkLastChangeAsPersistent } =
useDispatch( blockEditorStore );

const { createSuccessNotice, createErrorNotice } =
const { createSuccessNotice, createErrorNotice, removeNotice } =
useDispatch( noticesStore );

const { dirtyCurrentEntity, countUnsavedChanges, isDirty, isSaving } =
Expand Down Expand Up @@ -107,6 +108,7 @@ export default function SaveHub() {
const saveCurrentEntity = async () => {
if ( ! dirtyCurrentEntity ) return;

removeNotice( saveNoticeId );
const { kind, name, key, property } = dirtyCurrentEntity;

try {
Expand All @@ -132,6 +134,7 @@ export default function SaveHub() {

createSuccessNotice( __( 'Site updated.' ), {
type: 'snackbar',
id: saveNoticeId,
} );
} catch ( error ) {
createErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` );
Expand Down

1 comment on commit 736feac

@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 736feac.
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/5708426075
📝 Reported issues:

Please sign in to comment.