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

Remove #AppFrameMainContent link and update SkipToContent link to target #AppFrameMain instead #3912

Merged
merged 3 commits into from Feb 17, 2021

Conversation

henryyi
Copy link
Contributor

@henryyi henryyi commented Jan 25, 2021

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 of main.

WHAT is this pull request doing?

Remove the #AppFrameMainContent link from Frame. Update Skip to Content to target #AppFrameMain.

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Copy-paste this code in playground/Playground.tsx:
import React from 'react';
import {Page} from '../src';

export function Playground() {
  return (
    <Page title="Playground">
      {/* Add the code you want to test in here */}
    </Page>
  );
}

🎩 checklist

  • Tested on mobile
  • Tested on multiple browsers
  • Tested for accessibility
  • Updated the component's README.md with documentation changes
  • Tophatted documentation changes in the style guide
  • For visual design changes, pinged one of @ HYPD, @ mirualves, @ sarahill, or @ ry5n to update the Polaris UI kit

@ghost
Copy link

ghost commented Jan 25, 2021

👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 25, 2021

🟢 No significant changes to src/**/*.tsx were detected.

Copy link
Contributor

@kyledurand kyledurand left a 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

src/components/Frame/Frame.tsx Outdated Show resolved Hide resolved
ref={this.skipToMainContentTargetNode}
tabIndex={-1}
/>
);
Copy link
Contributor

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?

Copy link
Member

@BPScott BPScott Jan 25, 2021

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

@henryyi henryyi Jan 25, 2021

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BPScott yes I left the prop since it was needed according to this PR #2080

Copy link
Member

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?

@henryyi
Copy link
Contributor Author

henryyi commented Jan 27, 2021

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 <main> and using focusFirstKeyboardFocusableNode to focus on an item in <main> when the skipToContent link is clicked. However this makes the Voice Over experience worst since it will skip over non-focusable elements that it would usually read. For example if we just link to #AppFrameMain then the screen reader will read the first <h1> in <main>.

Top hatted in shop1 on chrome, ff and safari (macOS)

Copy link
Contributor

@mathildebuenerd mathildebuenerd left a 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

@BPScott BPScott removed their request for review February 2, 2021 02:54
@BPScott
Copy link
Member

BPScott commented Feb 2, 2021

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
@henryyi henryyi force-pushed the hyi/775-skip-to-content-target branch from 68d975d to ed8f201 Compare February 16, 2021 22:47
@henryyi henryyi added the Accessibility Needs design, development, or content work relating to accessibility. label Feb 17, 2021
@henryyi henryyi merged commit db429cd into main Feb 17, 2021
@henryyi henryyi deleted the hyi/775-skip-to-content-target branch February 17, 2021 01:33
@ghost
Copy link

ghost commented Feb 17, 2021

🎉 Thanks for your contribution to Polaris React!

sylvhama pushed a commit that referenced this pull request Mar 26, 2021
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility Needs design, development, or content work relating to accessibility.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants