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

Stop table of contents sticky header overlapping focused items #360

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

tombye
Copy link
Contributor

@tombye tombye commented Sep 17, 2024

Stop the table of contents sticky header, which appears on smaller screens, from overlapping interactice elements when they are focused.

A fix for #356, using a variant of the approach in https://www.tpgi.com/prevent-focused-elements-from-being-obscured-by-sticky-headers/.

What’s changed

Before

mobile_tech_docs_template_focus_obscured_fail

Tabbing backwards through content to a link obscured by the table of contents header means the focus indicator is lost.

After

mobile_tech_docs_template_focus_obscured_pass

Tabbing backwards through content to a link obscured by the table of contents header reveals the link when it it focused.

Notes for reviewers

This work is done on top of #358, because that adds tests for the table of contents JS that this adds to. So I don't need to duplicate the work adding them.

Identifying a user need

Users who use the keyboard to move through the page rely on being able to see what is focused to know where they are in the page.

The issue also failed success criterion 2.4.11, Focus not obscured (minimum) and success criterion 2.4.12, Focus not obscured (enhanced).

The table of contents header, which you see on
smaller screens, is sticky and so can overlap
elements when they are focused because the browser
will only scroll to reveal elements when they are
off-screen. As far as the browser knows, the
header and the focused element are both onscreen.

This takes an approach from the paciello group
where we listen for focus events, check if the
header overlaps the element in focus and scrolls
to reveal it if so.
@tombye tombye force-pushed the fix-toc-button-overlapping-focused-items branch from b9e3172 to 5da1476 Compare September 18, 2024 13:04
@tombye tombye marked this pull request as ready for review September 18, 2024 13:04
@tombye tombye changed the title [Do not merge until #358 is merged] Stop table of contents sticky header overlapping focused items Stop table of contents sticky header overlapping focused items Sep 19, 2024
Copy link
Contributor

@kr8n3r kr8n3r left a comment

Choose a reason for hiding this comment

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

works as expected 🎉

@tombye tombye merged commit 56da6ee into main Sep 19, 2024
3 checks passed
@tombye tombye deleted the fix-toc-button-overlapping-focused-items branch September 19, 2024 14:36
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