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

Prepublish Panel: Disable the Publish and Cancel buttons while saving #32889

Merged
merged 6 commits into from
Jun 29, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class PostPublishButton extends Component {
};

const buttonProps = {
'aria-disabled': isButtonDisabled && ! hasNonPostEntityChanges,
'aria-disabled': isButtonDisabled,
Addison-Stavlo marked this conversation as resolved.
Show resolved Hide resolved
className: 'editor-post-publish-button',
isBusy: ! isAutoSaving && isSaving && isPublished,
variant: 'primary',
Expand Down
30 changes: 30 additions & 0 deletions packages/editor/src/components/post-publish-button/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ describe( 'PostPublishButton', () => {
);
} );

it( 'should be true if post is currently saving, even if there are non-post entity changes', () => {
// This normally means that we're still saving those changes.
const wrapper = shallow(
<PostPublishButton
hasNonPostEntityChanges
isPublishable
isSaveable
isSaving
/>
);

expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
true
);
} );

it( 'should be true if forceIsSaving is true', () => {
const wrapper = shallow(
<PostPublishButton isPublishable isSaveable forceIsSaving />
Expand Down Expand Up @@ -96,6 +112,20 @@ describe( 'PostPublishButton', () => {
false
);
} );

it( 'should be false if there are non-post entity changes', () => {
const wrapper = shallow(
<PostPublishButton
hasNonPostEntityChanges
isPublishable
isSaveable
/>
);

expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
false
);
} );
} );

describe( 'publish status', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/editor/src/components/post-publish-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ export class PostPublishPanel extends Component {
/>
</div>
<div className="editor-post-publish-panel__header-cancel-button">
<Button onClick={ onClose } variant="secondary">
<Button
disabled={ isSaving }
onClick={ onClose }
variant="secondary"
>
{ __( 'Cancel' ) }
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ exports[`PostPublishPanel should render the pre-publish panel if the post is not
className="editor-post-publish-panel__header-cancel-button"
>
<ForwardRef(Button)
disabled={false}
variant="secondary"
>
Cancel
Expand Down Expand Up @@ -175,6 +176,7 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
className="editor-post-publish-panel__header-cancel-button"
>
<ForwardRef(Button)
disabled={true}
variant="secondary"
>
Cancel
Expand Down