-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove #AppFrameMainContent link and update SkipToContent link to target #AppFrameMain instead #3912
Conversation
👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines. |
🟢 No significant changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tophat looks fine here. Can you build for web and test on shop1 as well?
See: testing in a consuming project
Basically just dev up in web and then run:
yarn run build-consumer web
in polaris-react
ref={this.skipToMainContentTargetNode} | ||
tabIndex={-1} | ||
/> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this would be a bit of a breaking change. Are you sure we don't need this anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this seems half-done
Either: there's still a need for a skipToContentTarget prop - in which case we need to do something with it OR it's not needed anymore, in which case we need to add a @deprecated
docblock on the prop and documentation what has happened.
Is there still a use-case for a user-provided skipToMainContentTargetNode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell this is only used as a target for Skip To Content. I did a global search for AppFrameMainContent
and only see it referenced in Polaris and GlobalNav (which I updated here https://github.com/Shopify/global-nav/pull/859 as well).
However with that said please let me know if there are other places I should check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the reason this was removed is because focus was still being given to the anchor since it's technically a valid focusable element within <main>
. So by removing it, focus should go to a visible element in the content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading through this I think this change is fine. skipToContentTarget
either points towards APP_FRAME_MAIN
or the provided ref prop. This removes the private skipToMainContentTargetNode
and the link that is rendered. Is the risk that someone incorrectly referenced that element?
c828c14
to
14ed8a7
Compare
Minor update to remove the unused target ref. I also added preventDefault after focusing on custom targets so that it doesn't alter the hash. I considered keeping the target ref and placing it on Top hatted in shop1 on chrome, ff and safari (macOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice!
🎩 in Storybook on the Frame in an application component with Voiceover, and it works as expected. After clicking the skip link we are moved to the first focusable element in the main, in this case the h1
Removing myself from the reviewers list as I've moved off the polaris team |
…get #AppFrameMain instead Allow focus to be placed on a focusable element in <main> instead of invisible link
…tentTarget is clicked
68d975d
to
ed8f201
Compare
🎉 Thanks for your contribution to Polaris React! |
…get #AppFrameMain instead (#3912) * Remove #AppFrameMainContent link and update SkipToContent link to target #AppFrameMain instead * Allow focus to be placed on a focusable element in <main> instead of invisible link * Remove unnecessary anchor and add preventDefault when custom skipToContentTarget is clicked
WHY are these changes introduced?
References https://github.com/Shopify/global-nav/issues/775
The "Skip to Content" link by default targets a hidden anchor element within Frame via
#AppFrameMainContent
. This presents an accessibility concern since the focus does not advance to actual visible content item. This is also undesirable when Voice Over is activated since it will cause it to focus on and describe the hidden anchor.By targeting the main container (
#AppFrameMain
) instead the focus gets moved to the first focusable (or "voiceable") element inside ofmain
.WHAT is this pull request doing?
Remove the
#AppFrameMainContent
link from Frame. UpdateSkip to Content
to target #AppFrameMain.How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changes