Exit early from onClick handler when isButtonDisabled #12885
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
whenisButtonDisabled
is true (https://github.com/WordPress/gutenberg/pull/11543/files#diff-29409e4e3f779a199509ffadad068564L76) - insteadaria-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#r236177807How has this been tested?
Needs testing.
Types of changes
Add a check for
isButtonDisabled
in theonClick
handler, exit early if true - preventing click action handling.Checklist: