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: Use aria-disabled instead of disabled for undo/redo #11379

Merged
merged 1 commit into from
Nov 2, 2018

Conversation

tofumatt
Copy link
Member

@tofumatt tofumatt commented Nov 1, 2018

Fixes #3486

Description

Change the undo/redo buttons from using the disabled attribute and instead use the aria-disabled attribute; this prevents focus loss when the undo/redo actions are unavailable.

Note that there are no visual/functional differences here aside from screenreaders now announcing that the button becomes unavailable once disabled and focus is not lost as before.

@tofumatt tofumatt added this to the 4.3 milestone Nov 1, 2018
@tofumatt tofumatt requested a review from a team November 1, 2018 23:15
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

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

It works! 👍

I'm wondering, should this logic exist in Button and/or IconButton? Does this bug also exist in other places where we're using buttons with the disabled prop? It would be nice if developers could set the disabled prop on our Button component and rely on it doing the Right Thing™.

@noisysocks noisysocks added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Nov 2, 2018
@tofumatt
Copy link
Member Author

tofumatt commented Nov 2, 2018

It probably should, but I tried that in the past with some other buttons (in the Datepicker's ToggleButton) and it was enough of a refactor as to not be entirely trivial. I think it's just an easy place to hit up regressions, so I'd rather do it when we have more time to test things as there are a lot of buttons lacking in E2E tests and I don't want any Beta 3/4 regressions 😉

@tofumatt tofumatt merged commit ccb199e into master Nov 2, 2018
@tofumatt tofumatt deleted the fix/3486-focus-on-undo-empty branch November 2, 2018 09:45
redo: () => dispatch( 'core/editor' ).redo(),
withDispatch( ( dispatch, ownProps ) => ( {
redo: () => {
// If there are no redo levels this is a no-op, because we don't actually
Copy link
Member

Choose a reason for hiding this comment

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

In treating EditorHistoryRedo as the presentational component of the Presentational / Container pair, it seems like if it's meant to be a disabled behavior, it should be considered by the component in deciding to invoke the onClick callback.

Even something like:

onClick={ hasRedo ? redo : undefined }

It's not so much a concern here in that the components are so tied to the specific editor use case of Undo/Redo, but is a good rule of thumb in delegating where logic should occur between the underlying component and its enhancer(s).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good point. Follow-up PR with a fix is here: #11428.

tofumatt added a commit that referenced this pull request Nov 2, 2018
tofumatt added a commit that referenced this pull request Nov 8, 2018
* chore: Improve undo/redo no-op

See: #11379

* Do not wrap dispatch undo/redo
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.

3 participants