Skip to content

Commit

Permalink
Fix PostPublishButton toggle (#13194)
Browse files Browse the repository at this point in the history
Because we're using aria-disabled instead of the disabled property
the button is clickable. We need to back off from firing the onToggle
event if the toggle is disabled.
  • Loading branch information
nosolosw authored and youknowriad committed Jan 9, 2019
1 parent 204f7a0 commit b62e0f5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/editor/src/components/post-publish-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class PostPublishButton extends Component {
publishStatus = 'publish';
}

const onClick = () => {
const onClickButton = () => {
if ( isButtonDisabled ) {
return;
}
Expand All @@ -81,13 +81,20 @@ export class PostPublishButton extends Component {
onSave();
};

const onClickToggle = () => {
if ( isToggleDisabled ) {
return;
}
onToggle();
};

const buttonProps = {
'aria-disabled': isButtonDisabled,
className: 'editor-post-publish-button',
isBusy: isSaving && isPublished,
isLarge: true,
isPrimary: true,
onClick,
onClick: onClickButton,
};

const toggleProps = {
Expand All @@ -96,7 +103,7 @@ export class PostPublishButton extends Component {
className: 'editor-post-publish-panel__toggle',
isBusy: isSaving && isPublished,
isPrimary: true,
onClick: onToggle,
onClick: onClickToggle,
};

const toggleChildren = isBeingScheduled ? __( 'Schedule…' ) : __( 'Publish…' );
Expand Down

0 comments on commit b62e0f5

Please sign in to comment.