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

Fix disabled publish/update button still clickable #11760

Closed
wants to merge 2 commits into from
Closed

Fix disabled publish/update button still clickable #11760

wants to merge 2 commits into from

Conversation

glingener
Copy link
Contributor

@glingener glingener commented Nov 12, 2018

Description

Recently the disabled attribute for the publish/update button was replaced by aria-disabled to avoid focus loss.
fc03492

The problem with aria-disabled is that it won't block the functionality of the button - saving is still possible, using disabled will block the functionality as expected.

In addition aria-disabled on a button is agains W3C standards:

Only use the aria-disabled attribute for elements that are not allowed to have a disabled attribute in HTML5

https://www.w3.org/TR/html-aria/#attr-disabled

How has this been tested?

Open a post and click "Update" without any changes. The post does not save.

Types of changes

Replaced aria-disabled with disabled.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

Fixes #11809.

Copy link

@logicalphase logicalphase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any other benefit to having the save post button disabled? I'm not clear as to why the button condition needs to be disabled at all excepting a save in progress, but perhaps I'm missing the intended value otherwise. Thanks.

@glingener
Copy link
Contributor Author

@HyperPress for example you want to have some required fields and use wp.data.dispatch( 'core/editor' ).lockPostSaving( 'required-fields-not-filled' ); to block the save button until all required fields are filled.

Currently with the aria-disabled the whole save lock control feature is worthless. #10649

@@ -79,7 +79,7 @@ export class PostPublishButton extends Component {
};

const buttonProps = {
'aria-disabled': isButtonDisabled,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason we prefer 'aria-disabled' is to avoid focus loss when the status of the button changes. So instead we do 'aria-disabled' and return early on the onClick handler. Maybe we're missing the early return here.

Is this right @afercia ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not Andrea but yes that's right. We should be using aria-disabled and returning early from the onClick handler.

Copy link
Member

@noisysocks noisysocks Nov 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #12073:

From an accessibility perspective, using aria-disabled="true" and "noop'ing" an UI control is equivalent to disabling it with a disable attribute, as long as it is perceived as disabled by all users, i.e. also visually. The relevant difference is that a control with aria-disabled="true" is still focusable. Removing focusability from disabled elements can offer users both advantages and disadvantages. A must read recommendation can be found in the ARIA authoring practices:

5.7 Focusability of disabled controls
https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_disabled_controls

Although those recommendations apply to ARIA widgets, the Gutenberg top bar can be considered a "toolbar", where the ability to discover the functionalities within the toolbar is a primary concern. I'd recommend to adopt a consistent convention for the focusability of these controls and always use aria-disabled="true" / "noop". The Block navigation menu should not open its panel when there are no blocks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late reply but yes: when there's the need to avoid a focus loss (as when a focused button gets disabled while it's focused), it's possible to use aria-disabled and noop it. At that point, the only difference is that the button is still focusable. This can offer both advantages and disadvantages, to be evaluated on a case by case basis. For more details:

5.7 Focusability of disabled controls
https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_disabled_controls

@youknowriad youknowriad added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Nov 26, 2018
@logicalphase
Copy link

I wonder then if the main problem is in the sequence/timing as currently aria-disabled in this case does not prevent actions on the button. Investigating further. Thank you all for your feedback and clarifications.

@mtias mtias added this to the 4.8 milestone Nov 29, 2018
@adamsilverstein
Copy link
Member

currently aria-disabled in this case does not prevent actions on the button

Exactly! The only/main thing we need to do in the PR is prevent the click handlers when the button is disabled.

@adamsilverstein adamsilverstein modified the milestones: 4.8, WordPress 5.0.1 Dec 3, 2018
@youknowriad youknowriad modified the milestones: WordPress 5.0.1, 4.8 Dec 3, 2018
@adamsilverstein
Copy link
Member

oops, thanks for fixing that milestoning @youknowriad - i was confused about how the milestones are being used.

@youknowriad
Copy link
Contributor

youknowriad commented Dec 3, 2018

No worries so we basically put WordPress * milestones for issues and 4.* for PRs.

@adamsilverstein
Copy link
Member

@CGlingener I created an alternate solution that exists early from the onClick event handler if the button is disabled, can you test and verify this resolves your issue: #12885

@afercia
Copy link
Contributor

afercia commented Dec 15, 2018

Note: I've created an issue on the W3C "ARIA in HTML" GitHub to consider to clarify the current wording for aria-disabled. See w3c/html-aria#122

Worth also considering "ARIA in HTML" is still a working draft. Instead, the relevant spec to take into consideration is ARIA 1.1 and, for the future, ARIA 1.2:
https://www.w3.org/TR/wai-aria-1.1/#aria-disabled
https://www.w3.org/TR/wai-aria-1.2/#aria-disabled

@youknowriad
Copy link
Contributor

Thanks for your work here, this is superseded by #12885

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants