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

[Site] Fix mobile tabindex #5426

Merged
merged 8 commits into from
Feb 25, 2021
Merged

[Site] Fix mobile tabindex #5426

merged 8 commits into from
Feb 25, 2021

Conversation

paulcam206
Copy link
Member

@paulcam206 paulcam206 commented Feb 24, 2021

Related Issue

Fixes VSO 30943285

Description

I apologize in advance. Header and mobile nav is powered by some JS we don't own (and can't change on any reasonable time scale). There are a couple of problems with this script. The first is that it puts explicit positive tabindex attributes on some DOM elements when in what it considers to be a "mobile" view (this is keyed off of the window width, so it is also affected by DPI and zoom levels). Using positive tabindex values is considered bad practice because it's easy to get wrong. Anyways, this is the reason why the tab order is messed up in mobile. The second (relatively minor) problem is that it views the templating checkbox as a search box (it just looks for the first <input /> in the DOM).

The fix reads easy enough, but I'm not proud of it (though it works):

  • Add an explicit tabindex="0" to the templating checkbox to give it a reasonable default.
  • Introduce makeTabIndicesZero(), which finds everything on the page that has a tabindex property, and then sets that property to 0 as it should be.
  • Call makeTabIndicesZero() on window resize (covers active zooming case).
  • Call makeTabIndicesZero() on document load, but do it behind a setTimeout call so that it runs after the offending JS. This is the part I'm least happy about, but the offending JS is itself being run something like setTimeout(ruinSomeTabIndices, 4); (yes, 4).

How Verified

  • local build, devtools, keyboard
Microsoft Reviewers: Open in CodeFlow

Fixes VSO 30943285
@ghost
Copy link

ghost commented Feb 24, 2021

Hi @paulcam206. Thanks for helping make the AdaptiveCards JS renderer + tooling better. As additional verification, once the JS build succeeds, please go to the test site to test out your website/designer changes.

@RebeccaAnne
Copy link
Contributor

Heh. This will do it i guess, but is there a way to like log a bug against whoever does own the bad script so that someday eventually their script will be less broken?

Copy link
Contributor

@RebeccaAnne RebeccaAnne left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Member

@golddove golddove left a comment

Choose a reason for hiding this comment

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

If we have less than 5 pending accessibility issues, we should consider waiting for a proper UHF fix instead. Either that, or track a new issue to change it.

@@ -595,6 +595,20 @@ $(function () {
// Kick off one resize to fix all videos on page load
}).resize();

function makeTabIndicesZero() {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should only make the indices zero if they're not set to a negative number? This way, if anything was explicitly removed from tab order, we don't change those.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a good point -- fix inbound shortly

@paulcam206
Copy link
Member Author

If we have less than 5 pending accessibility issues, we should consider waiting for a proper UHF fix instead. Either that, or track a new issue to change it.

unfortunately, I don't think we can count on a fix coming any time soon. we're basically using a cobbled-together UHF drop, so we're not likely to be in a supported config. that said, we should probably file an issue to modernize our UHF consumption. I'll do that. :)

@paulcam206 paulcam206 merged commit 45633c0 into main Feb 25, 2021
@paulcam206 paulcam206 deleted the paulcam/fix-mobile-tabindex branch February 25, 2021 19:07
@golddove golddove added this to the 21.02 milestone Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Accessibility Bugs around feature accessibility Area-Website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants