Skip to content

Exit early from onClick handler when isButtonDisabled#12885

Merged
youknowriad merged 2 commits into
masterfrom
fix/disable-disabled
Dec 21, 2018
Merged

Exit early from onClick handler when isButtonDisabled#12885
youknowriad merged 2 commits into
masterfrom
fix/disable-disabled

Conversation

@adamsilverstein
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein commented Dec 14, 2018

Description

Fixes #11809
Alternate/replaces #11760

Return early from click action handling when button is disabled (isButtonDisabled is true)

Since #11543 the post publish/update button is no longer disabled when isButtonDisabled is true (https://github.com/WordPress/gutenberg/pull/11543/files#diff-29409e4e3f779a199509ffadad068564L76) - instead aria-diabled is set to true (https://github.com/WordPress/gutenberg/pull/11543/files#diff-29409e4e3f779a199509ffadad068564L76) which still allows the button itself to be clicked.

This PR prevents the button from being clicked by returning early from the onClick handler, see @youknowriad's comment here: https://github.com/WordPress/gutenberg/pull/11760/files#r236177807

How has this been tested?

Needs testing.

Types of changes

Add a check for isButtonDisabled in the onClick handler, exit early if true - preventing click action handling.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@adamsilverstein adamsilverstein changed the title disable onClick event when button is disabled (isButtonDisabled) Exit early from onClick event when publish/update isButtonDisabled Dec 14, 2018
@adamsilverstein adamsilverstein changed the title Exit early from onClick event when publish/update isButtonDisabled Exit early from onClick handler when isButtonDisabled Dec 14, 2018
@gziolo gziolo added the [Type] Bug An existing feature does not function as intended label Dec 16, 2018
@gziolo gziolo requested a review from youknowriad December 16, 2018 20:06
@adamsilverstein
Copy link
Copy Markdown
Member Author

thanks for the review... not sure why checks are failing here, @youknowriad they pass for me locally

@youknowriad
Copy link
Copy Markdown
Contributor

The tests are broken across the repository (some weird docker failures), @gziolo is working on them, we should rebase once everything is on track again.

@adamsilverstein
Copy link
Copy Markdown
Member Author

we should rebase once everything is on track again.

👍 I'll wait for that then merge once I see tests passing.

@youknowriad youknowriad added this to the 4.8 milestone Dec 19, 2018
@gziolo
Copy link
Copy Markdown
Member

gziolo commented Dec 19, 2018

You can rebase now. Travis is back to normal.

@youknowriad youknowriad merged commit 9b607fa into master Dec 21, 2018
@youknowriad youknowriad deleted the fix/disable-disabled branch December 21, 2018 09:06
youknowriad pushed a commit that referenced this pull request Jan 3, 2019
* disable onClick event when button is disabled

* clean up unit tests after click handler change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants