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

init: add skip-to-main-content shortcut #7390

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yaten2302
Copy link

Description

This PR adds a skip to main content button (initially hidden), when the user presses Tab(for windows), the button is visible and the user can then move directly to the main content of the page.

Related Issues

Fixes #7220

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npm run format to ensure the code follows the style guide.
  • I have run npm run test to check if all tests are passing.
  • I have run npx turbo build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@yaten2302 yaten2302 requested a review from a team as a code owner January 7, 2025 06:57
Copy link

vercel bot commented Jan 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Jan 7, 2025 5:28pm

@yaten2302
Copy link
Author

yaten2302 commented Jan 7, 2025

I think currently on pressing Tab, the button is shown, but it's not getting pressed if the user presses Enter, I forgot take into account the Enter button, I'll push a commit for this too 👍

Edit: Sorry, will not ping 👍

@AugustinMauroy
Copy link
Member

WOW stop pinging everyone ! we (website team) receive notification when there are changes on repo.

apps/site/components/withNavBar.tsx Show resolved Hide resolved
apps/site/components/withNavBar.tsx Outdated Show resolved Hide resolved
apps/site/components/withNavBar.tsx Outdated Show resolved Hide resolved
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Comment on lines 33 to 37
const handleTabPress = (event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Tab') {
setTabPressed(prev => !prev);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

That's very wrong, we should not rely on keyboard event, it's arbitrary restrictive. In fact we shouldn't be using JS at all, there's no reason this couldn't be CSS-only

Copy link
Author

Choose a reason for hiding this comment

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

Got your point, I'll make it CSS-only and remove all the JS 👍

Copy link
Author

Choose a reason for hiding this comment

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

I've made the change CSS-only, but I've a doubt that what should be the bg-color of the button? I wasn't able to find it in the component. Currently I've set it to black, for testing purposes only!!


const toggleCurrentTheme = () =>
setTheme(resolvedTheme === 'dark' ? 'light' : 'dark');

return (
<div>
<a className={classNameOnTabPress} href="#main">
Copy link
Member

Choose a reason for hiding this comment

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

Anchor href is not working, main element is missing the id attribute.

@@ -16,13 +17,23 @@ const WithNavBar: FC = () => {
const { replace } = useRouter();
const pathname = usePathname();

const classNameOnTabPress = classNames(
Copy link
Member

Choose a reason for hiding this comment

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

I believe that creating a SkipToContentButton component would make this cleaner.

Copy link
Member

Choose a reason for hiding this comment

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

And I feel that WithLayout is a better place to put this component.

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.

Adding a "Skip to Content" Link
5 participants