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(commons/dom): change isFocusable to use unfocusableBecauseHidden #654

Closed
wants to merge 1 commit into from

Conversation

0ddfell0w
Copy link
Contributor

@0ddfell0w 0ddfell0w commented Dec 15, 2017

change isFocusable to use unfocusableBecauseHidden function instead of isVisible

Adds functionality for detecting when hidden elements are still
focusable or in focus order.

fixes #647

Demo showing that off-screen and clipped elements remain in the focus order, where display:none and visibility:hidden elements do not (they are totally unfocusable)

@0ddfell0w 0ddfell0w force-pushed the invisible-focusable branch 2 times, most recently from 60fe2c8 to 783920e Compare December 15, 2017 17:58
method instead of isVisible

Adds functionality for detecting when hidden elements are still
focusable or in focus order.

fixes dequelabs#647
@dylanb
Copy link
Contributor

dylanb commented Dec 15, 2017

Ok, this commit is totally confusing

isVisible has two modes:

  1. screen reader mode - where content that is clipped, offscreen or otherwise accessible to the screen reader (or a keyboard) will return true if "visible" or false otherwise, and
  2. default mode, where it will return true if the content is visible to sighted users AND screen readers

It seems like this same change could be achieved by calling !isVisible in screen reader mode.

@0ddfell0w
Copy link
Contributor Author

Sure, that's fine too

@dylanb
Copy link
Contributor

dylanb commented Dec 15, 2017

@0ddfell0w @WilcoFiers I do wonder whether this new method might introduce some performance improvements though - thoughts on this versus "duplicate code"?

@0ddfell0w
Copy link
Contributor Author

#655 for your suggestion

* @param {Element} el
* @return {Boolean} Whether the element is unfocusable due to being hidden
*/
function unfocusableBecauseHidden (el) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we keep this for performance - what about parent-child relationships? This function is a bit naive - look at isVisible for all the conditions that must be handled. Also add tests to handle all those conditions.

Copy link
Contributor

Choose a reason for hiding this comment

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

@0ddfell0w 0ddfell0w closed this Dec 15, 2017
@0ddfell0w 0ddfell0w reopened this Dec 18, 2017
@0ddfell0w 0ddfell0w closed this Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: dom.isFocusable mistakenly concludes that invisible elements are unfocusable
2 participants