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

feat(web): navigate with keyboard on person page #5486

Merged
merged 7 commits into from Feb 13, 2024

Conversation

martabal
Copy link
Member

@martabal martabal commented Dec 4, 2023

Changes made in this PR

With this PR, users can navigate through suggested people with Tab and Arrow keys. On the suggestion merge modal, pressing the Tab key will only switch between the No and Yes buttons.

Resolves #5400 and #5398

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

Can you use svelte:document instead please?

https://svelte.dev/docs/special-elements#svelte-document

if (!$showAssetViewer) {
event.stopPropagation();
switch (event.key) {
case 'Tab':
Copy link
Contributor

Choose a reason for hiding this comment

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

Tabbing through focusable elements is something that is built into the browser. We don't need to re-invent the wheel here.

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I know but I couldn't find a way to limit the focus to the suggested people only.

Copy link
Contributor

Choose a reason for hiding this comment

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

tabindex=-1 tells the browser to skip it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I tried it but the issue is that you want to navigate only through the suggested people, not all the buttons on the page. Do you have any ideas 🤔 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does using an actual browser model still let you focus on background elements?

Copy link
Member Author

Choose a reason for hiding this comment

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

What's an actual browser model ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmmh, just tried it, does it work only for dialogs ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we want dialogs to display suggested people 😅

@martabal martabal changed the title feat: navigate with keyboard on person page feat(web): navigate with keyboard on person page Dec 15, 2023
@jrasm91
Copy link
Contributor

jrasm91 commented Jan 2, 2024

I think it is fine to add keyboard shortcuts, but we should do it in a way that doesn't make the site less accessible (which is the outcome of overriding the tab behavior or preventing other default key behaviors)

@martabal
Copy link
Member Author

martabal commented Jan 9, 2024

I think it is fine to add keyboard shortcuts, but we should do it in a way that doesn't make the site less accessible (which is the outcome of overriding the tab behavior or preventing other default key behaviors)

I agree 100% with you. But in this case we want to navigate with the tabs and arrow keys which is a little unusual. I don't know what's the good way for that case 😅

@jrasm91
Copy link
Contributor

jrasm91 commented Jan 9, 2024

Can you just use arrow keys and enter instead?

Copy link

cloudflare-pages bot commented Feb 10, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 46d7456
Status: ✅  Deploy successful!
Preview URL: https://1ac984d2.immich.pages.dev
Branch Preview URL: https://feat-keyboard-navigation-per.immich.pages.dev

View logs

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

LGTM

@jrasm91 jrasm91 merged commit dcfd1f9 into main Feb 13, 2024
24 checks passed
@jrasm91 jrasm91 deleted the feat/keyboard-navigation-person-pag branch February 13, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants