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

Prevent <a> tag from being focusable (via tabbing) when inside <Disabled> component. #24397

Conversation

yansern
Copy link
Contributor

@yansern yansern commented Aug 6, 2020

When <a> tag is inside the <Disabled>, it is focusable via tabbing, therefore causing unintended consequences.

One such example is when the <a> tag presents itself inside block previews on block pattern list on the block inserter menu, it causes the <a> to receive focus, and activates the block toolbar unintentionally.

See more detail of this issue at: Automattic/wp-calypso#44042

Description

Set tabindex=-1 specifically on <a> nodes when inside <Disabled> component.

How has this been tested?

  1. Tab through the block pattern list.
  2. It should not activate the block toolbar.

Screenshots

See Automattic/wp-calypso#44042

Types of changes

Bug fix

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.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

This makes sense to me.

@@ -47,6 +47,10 @@ function Disabled( { className, children, ...props } ) {
focusable.setAttribute( 'disabled', '' );
}

if ( focusable.nodeName=='A' ) {
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 there are some linting issues here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

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). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants