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(frame-focusable-content): don't fail for elements with negative tabindex #3493

Merged
merged 4 commits into from
Jun 3, 2022

Conversation

straker
Copy link
Contributor

@straker straker commented Jun 1, 2022

Updated the isFocusable code since we were looking at it to 1) default export at top and 2) update the description as we spent a bit of time trying to figure out why an element with tabindex=-1 was still considered focusable.

Also, having the frame-focusable-content test have all the elements wrapped in buttons was strange so changed them to divs

Closes issue: #3466

@straker straker requested a review from a team as a code owner June 1, 2022 23:08
@straker straker changed the title fix(frame-focsuable-content): don't fail for elements with negative tabindex fix(frame-focusable-content): don't fail for elements with negative tabindex Jun 1, 2022
@@ -45,13 +45,6 @@ describe('frame-focusable-content tests', function() {
assert.isTrue(frameFocusableContent(null, null, vNode));
});

it('should return false if element is natively focusable but has tabindex', function() {
Copy link
Contributor Author

@straker straker Jun 1, 2022

Choose a reason for hiding this comment

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

Turns out IE11 will take the empty tabindex and default it to -3876. But that value of tabindex also didn't prevent the browser from tabbing to the element so ¯\(ツ)

lib/checks/keyboard/frame-focusable-content-evaluate.js Outdated Show resolved Hide resolved
* @method isFocusable
* @memberof axe.commons.dom
* @instance
* @param {HTMLElement} el The HTMLElement
* @return {Boolean} The element's focusability status
*/

function isFocusable(el) {
export default function isFocusable(el) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if maybe we should add some option here to say isFocusable(el, { noNegativeTabindex: true })?

This seem like sort of a common occurance.

Copy link
Contributor Author

@straker straker Jun 3, 2022

Choose a reason for hiding this comment

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

I agree. Though maybe the option could be called programmatically? Either way we should do it in a separate pr.

const focusable = isFocusable(el, { programmatically: false })

Copy link
Contributor Author

@straker straker Jun 3, 2022

Choose a reason for hiding this comment

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

Created #3500

var vNode = queryFixture('<button id="target"><span>Hello</span></button>');
var vNode = queryFixture('<div id="target"><span>Hello</span></div>');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you have to change these?

Copy link
Contributor Author

@straker straker Jun 3, 2022

Choose a reason for hiding this comment

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

having the frame-focusable-content test have all the elements wrapped in buttons was strange so changed them to divs

The <button><a></a></button> setup was the one that was the most strange

Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
@straker straker merged commit 94e75ac into develop Jun 3, 2022
@straker straker deleted the frame-focusable-negative-tabindex branch June 3, 2022 15:35
straker added a commit that referenced this pull request Jul 13, 2022
…abindex (#3493)

* fix(frame-focsuable-content): don't fail for elements with negative tabindex

* revert playground'

* remove test case

* Update lib/checks/keyboard/frame-focusable-content-evaluate.js

Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>

Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
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.

2 participants