Skip to content

fix(a11y): move readme above sidebar in package view for mobile layout#1072

Draft
knowler wants to merge 1 commit intonpmx-dev:mainfrom
knowler:package-dom-order-match-visual-order
Draft

fix(a11y): move readme above sidebar in package view for mobile layout#1072
knowler wants to merge 1 commit intonpmx-dev:mainfrom
knowler:package-dom-order-match-visual-order

Conversation

@knowler
Copy link
Contributor

@knowler knowler commented Feb 6, 2026

Resolves #1069 which reports a WCAG 2.2 SC 2.4.3 Focus Order (Level A) failure.

See the linked issue. This PR goes with the easiest solution to the problem which is just making the DOM order match the visual order as that’s how the tablet/desktop view works (for screen readers). I am open to the other solutions I mentioned in the issue (someone else just might need to implement them).

As I mentioned in the issue, I think we could improve on the mobile experience by making the README section collapsible, at least on mobile. I did see the <CollapsibleSection> component, however, the code for it made me think it might have been designed for the sidebar and might not work well for the README section.

We can always hold this PR until we figure out a solution for that. This is such a small change that it shouldn’t be hard to update.

This is to solve a level A WCAG failure (SC 2.4.3).
@vercel
Copy link

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 6, 2026 5:15am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 6, 2026 5:15am
npmx-lunaria Ignored Ignored Feb 6, 2026 5:15am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

This pull request adjusts the mobile layout grid structure in the package view component. The grid-template-areas order has been modified to reorder how sections are displayed on mobile devices. Specifically, the layout now positions the readme section and sidebar differently to ensure the visual grid order aligns with the document object model (DOM) order, addressing a focus order accessibility issue identified in the linked WCAG 2.2 compliance check.

Possibly related PRs

Suggested reviewers

  • danielroe
  • trueberryless
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements solution 1 from issue #1069 by adjusting the mobile grid layout to match DOM order with visual order, resolving the WCAG 2.4.3 focus-order failure.
Out of Scope Changes check ✅ Passed The changes are limited to adjusting mobile grid-template-areas in the package view file, directly addressing the focus-order issue without introducing unrelated modifications.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining that it resolves a WCAG focus order issue by reordering the mobile layout's grid-template-areas to match visual order.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@knowler knowler changed the title fix(a11y): move readme above sidebar in package view fix(a11y): move readme above sidebar in package view for mobile layout Feb 6, 2026
Copy link
Contributor

@43081j 43081j left a comment

Choose a reason for hiding this comment

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

i think this is good for now and, if you do rework it, lets just open a follow up PR

EDIT: just seen alex's response below so ill hold off for now until discord/discussion resolves

@alexdln
Copy link
Contributor

alexdln commented Feb 6, 2026

I agree that the order needs to be changed (discord), but I disagree about the reason. If the problem is only with A11Y, we need to change the order of the elements in the DOM (make <Sidebar> higher than <Readme>).

As for the visual reordering, I think it's better to decide what experience we want to achieve (maybe for example collapsing sidebar sections on mobile devices is better)

@knowler
Copy link
Contributor Author

knowler commented Feb 6, 2026

In #1072 (comment), @alexdln said:

If the problem is only with A11Y, we need to change the order of the elements in the DOM (make higher than ).

If we did that it would cause the same WCAG failure for the “tablet” and desktop layouts because they would no longer match their grid order. Moving DOM specifically when the mobile breakpoint matches (i.e. using MediaQueryList.addListener() or whatever Vue abstraction exists) could solve that, however, that will inherently be less performant than using CSS itself and it would leave the no-JS experience inaccessible (because it wouldn’t be able to change the order).

It’s that complexity and “whack-a-mole” problem that I’m trying to address with this PR. To make matters simple: DOM order must match the visual order for every breakpoint (without the help of JavaScript). I’m doing so at the cost of design, but it was a design that should never have been tenable because it did not consider accessibility.

With all of that said, if we want to revisit the visual order that’s totally fine. The purpose of this PR less so to make a design change and more so to remediate the accessibility issue in a way that is most performant and universal (i.e. it works with whatever no-JS experience there is).

@alexdln
Copy link
Contributor

alexdln commented Feb 6, 2026

If we did that it would cause the same WCAG failure for the “tablet” and desktop

It shouldn't. Navigation, toc, and priority elements to the right and left of main content are fairly standard practice.

The current complaint was that focus jumping abruptly to the bottom of the page, and that shouldn't happen. With the option I'm talking about, focus should move correctly, since our right panel is sticky

@knowler
Copy link
Contributor Author

knowler commented Feb 6, 2026

In #1072 (comment), @alexdln said:

It shouldn't. Navigation, toc, and priority elements to the right and left of main content are fairly standard practice.

That’s a really fair point.

The current complaint was that focus jumping abruptly to the bottom of the page, and that shouldn't happen. With the option I'm talking about, focus should move correctly, since our right panel is sticky

With your option applied, I think the desktop view is fine. The focus jump remains in view.

In the “tablet” view (I use a 14" laptop so I get this view if I open the vertical-tab-sidebar in my browser, which is pretty much always), it is a bit strange when the focus initially moves to the right column instead of the left column when traversing through the page.

At this breakpoint, the “Getting started” + “vulnerabilities” sections are both comically wide when they don’t need to be. If we make both of them only take up one column and bump the sidebar up, that improves the experience to be more like desktop (and makes it look nicer IMO).

Proposed grid layout change for tablet view

 @media (min-width: 1024px) {
   .package-page {
     grid-template-columns: 2fr 1fr;
     grid-template-areas:
       'header  header'
       'details details'
-      'install install'
+      'install sidebar'
-      'vulns   vulns'
+      'vulns   sidebar'
       'readme  sidebar';
     grid-template-rows: auto auto auto auto 1fr;
   }
 }

What do you think?

As for the visual reordering, I think it's better to decide what experience we want to achieve (maybe for example collapsing sidebar sections on mobile devices is better)

I agree and, yes, I think collapsing the sidebar sections on mobile would be a good fix.

@alexdln
Copy link
Contributor

alexdln commented Feb 6, 2026

lgtm about tablet (source)

image

@ghostdevv ghostdevv marked this pull request as draft February 6, 2026 22:18
@ghostdevv
Copy link
Contributor

(marking as draft while you work on it)

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.

Focus order does not follow visual order in mobile layout of the package view

4 participants