Skip to content
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
3 changes: 1 addition & 2 deletions packages/edit-site/src/components/save-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ const EntitiesSavedStatesForPreview = ( {
);

const activateTheme = useActivateTheme();
const onSave = async ( values ) => {
const onSave = async () => {
await activateTheme();
return values;
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import { useIsDirty } from './hooks/use-is-dirty';
import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';

function identity( values ) {
return values;
}

/**
* Renders the component for managing saved states of entities.
*
Expand Down Expand Up @@ -79,7 +75,7 @@ export default function EntitiesSavedStates( {
export function EntitiesSavedStatesExtensible( {
additionalPrompt = undefined,
close,
onSave = identity,
onSave = undefined,
saveEnabled: saveEnabledProp = undefined,
saveLabel = __( 'Save' ),
renderDialog,
Expand Down
8 changes: 6 additions & 2 deletions packages/editor/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,13 @@ export const saveDirtyEntities =
registry
.dispatch( blockEditorStore )
.__unstableMarkLastChangeAsPersistent();

Promise.all( pendingSavedRecords )
.then( ( values ) => {
return onSave ? onSave( values ) : values;
.then( async ( values ) => {
if ( onSave ) {
await onSave();
}
return values;
Comment on lines +215 to +218

@mcsf mcsf Jul 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This looks a little awkward due to the Promise#then-based syntax, but I preferred to keep this patch tiny rather than refactor everything to use async / await.

I kept a dedicated .then block before the main one so that we wait for onSave() to resolve. @scruffian, I assumed that this would be relevant for the theme-activation scenario, but let me know if we can/should run the onSave and error handling in parallel.

I'm also noticing that, even though we're no longer looking at the return value of onSave, if that function throws it will engage the final .catch block — meaning that we will dispatch a "Saving failed" notice even if saving itself was successful. Is that acceptable, or should we catch and ignore errors from onSave? IMO it's a matter of balancing complexity and real usage, so maybe it's fine as is.

} )
.then( ( values ) => {
if (
Expand Down
Loading