Skip to content

Commit

Permalink
small fix to show publish panel if no other entities changes exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Jun 26, 2024
1 parent 0e8039b commit 9b64e70
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
47 changes: 25 additions & 22 deletions packages/editor/src/components/save-publish-panels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,30 @@ export default function SavePublishPanels( {
} ) {
const { closePublishSidebar, togglePublishSidebar } =
useDispatch( editorStore );
const { publishSidebarOpened, isPublishable, isDirty } = useSelect(
( select ) => {
const {
isPublishSidebarOpened,
isEditedPostPublishable,
isCurrentPostPublished,
isEditedPostDirty,
hasNonPostEntityChanges: _hasNonPostEntityChanges,
} = select( editorStore );
return {
publishSidebarOpened: isPublishSidebarOpened(),
isPublishable:
! isCurrentPostPublished() && isEditedPostPublishable(),
isDirty:
_hasNonPostEntityChanges() ||
isEditedPostDirty() ||
unlock( select( editorStore ) ).hasPostMetaChanges(),
};
},
[]
);
const {
publishSidebarOpened,
isPublishable,
isDirty,
hasOtherEntitiesChanges,
} = useSelect( ( select ) => {
const {
isPublishSidebarOpened,
isEditedPostPublishable,
isCurrentPostPublished,
isEditedPostDirty,
hasNonPostEntityChanges,
} = select( editorStore );
const _hasOtherEntitiesChanges =
hasNonPostEntityChanges() ||
unlock( select( editorStore ) ).hasPostMetaChanges();
return {
publishSidebarOpened: isPublishSidebarOpened(),
isPublishable:
! isCurrentPostPublished() && isEditedPostPublishable(),
isDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),
hasOtherEntitiesChanges: _hasOtherEntitiesChanges,
};
}, [] );

const openEntitiesSavedStates = useCallback(
() => setEntitiesSavedStatesCallback( true ),
Expand All @@ -67,7 +70,7 @@ export default function SavePublishPanels( {
PostPublishExtension={ PluginPostPublishPanel.Slot }
/>
);
} else if ( isPublishable ) {
} else if ( isPublishable && ! hasOtherEntitiesChanges ) {
unmountableContent = (
<div className="editor-layout__toggle-publish-panel">
<Button
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/editor/various/multi-entity-saving.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ test.describe( 'Editor - Multi-entity save flow', () => {
await expect( saveButton ).toBeEnabled();

// Verify multi-entity saving not enabled.
await expect( openSavePanel ).toBeHidden();
await expect( publishPanel ).toBeHidden();

await siteTitleField.fill( `${ originalSiteTitle }!` );

// Multi-entity saving should be enabled.
await expect( openSavePanel ).toBeVisible();
await expect( openSavePanel ).toBeEnabled();
} );

test( 'Site blocks should save individually', async ( {
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/specs/editor/various/switch-to-draft.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ test.describe( 'Clicking "Switch to draft" on a published/scheduled post/page',
.getByRole( 'button', { name: 'Close Settings' } )
.click();
}
await page.getByRole( 'button', { name: 'Save' } ).click();
await page
.getByRole( 'button', { name: 'Save', exact: true } )
.click();
await expect(
page.getByRole( 'button', {
name: 'Dismiss this notice',
Expand Down

0 comments on commit 9b64e70

Please sign in to comment.