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
[docs] Add a shortcut to access the search bar #23959
Conversation
@mnajdova I have experimented a bit with using the system over makeStyles in 0e09c6e. I have faced an issue with TypeScript, that I have tried to solve with the diff you can see. However, I gave up on the idea of pushing it further. The results of https://github.com/mui-org/material-ui/blob/next/benchmark/browser/README.md#output made me too worried about the performance. I think that for the migration, better to use the styled() API here. I wanted to name the component anyway. |
classes={{ | ||
root: classes.inputRoot, | ||
input: classes.inputInput, | ||
}} | ||
/> | ||
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */} | ||
<div className={clsx(classes.shortcut, { 'Mui-focused': focused })}>/</div> |
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.
We should display the dual-key keyboard shortcut here instead so that it's more apparent what this is supposed to do. We're currently using the most exotic shortcut.
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.
We are leveraging what GitHub is teaching developers. I think that we better display it this way. Using / is a common convention.
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.
Using / is a common convention.
Please explain how you define common.
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.
"common" as a shortcut our audience has already learned, so they can keep previous habits. e.g. GitHub, Gmail, DocSearch, Twitter, Apollo docs.
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.
How do you know that the audience has learned it?
e.g. GitHub, Gmail, DocSearch, Twitter, Apollo docs.
Please make this exhaustive. I just want to be able to work with you in feature PRs. So far you change you references every time and it would be nice to know if these are actual principles or just smoke screens for "I just prefer it that way".
PS:
Why do you exclude e.g. testing-library.com (or any docosaurus v2? for that matter).
PPS: Could you clarify why we want all 3 shortcuts? On one side you say "use these reference". But some of those I'm not sure where they implement /
(gmail) or they only implement /
not the other ones.
PPPS:
- github: displays and implement
/
, noCTRL+K
- gmail: unclear where they implement it
- docsearch: displays CTRL+K, implements
/
(looks like the same template as testing-library.com) - twitter: does not display
/
but implements it, noCTRL+K
- apollo docs: display and implement
/
What standard was applied here that you all consider these as arguments for "display /
, implement s
, /
and CTRL+K"
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.
@eps1lon Considering it's a detail and that we can probably solve my previous concern of visual distraction by reducing the contrast of the displayed shortcut, I think that if you think strongly about it, we can move forward with displaying Ctrl + K by default.
I also think that supporting /
and s
is important. Maybe we could solve #23959 (comment) with 2. for these two shortcuts and support Ctrl + K with the current detection logic?
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.
I think that we have spent enough time on the topic, relative to its importance.
You have no arguments anymore.
I also think that supporting / and s is important.
Why?
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.
Why?
Developers have learned this shortcut, it's a habit for some. I think that we can improve the UX for them by supporting these shortcuts.
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.
Developers have learned this shortcut
What's your evidence for that? Why does this not apply to ctrl+k?
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.
Ok, let's drop them and wait for developers to complain (maybe they will never do).
const matchKey = | ||
((nativeEvent.ctrlKey || nativeEvent.metaKey) && nativeEvent.key === 'k') || | ||
nativeEvent.key === '/' || | ||
nativeEvent.key === 's'; |
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.
Why do we need 3 keyboard shortcuts?
Especially s
is problematic. The WCAG guideline to avoid single keys exists for a reason. For example, try our Select components type-ahead feature. On https://deploy-preview-23959--material-ui.netlify.app/components/selects/#basic-select focus the select, open it, and press s
. The searchbox will now take focus and our trapfocus will return it to the container i.e. it will focus an element that is not matching what the user typed. On next
nothing happens as expected (https://next--material-ui.netlify.app/components/selects/#basic-select).
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.
Oh nice, we need to improve the logic that filters active elements.
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.
WCAG guideline to avoid single keys exists for a reason.
The reason seems to be about speech users, by a large margin. They dedicate a lot of the content to it. I couldn't find our conflict problem covered.
Regarding the solution, I could find 3 options:
- We ignore it.
- We only handle the keyboard shortcut when body and main are focused.
- We add
.defaultMuiPrevented
to signal that the event was already handled. - Else?
I'm happy with any of these, maybe a slight preference for 2 as a quick win. Thoughts?
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.
We ignore it.
So we're re-opening the discussion about WCAG again. We settled on AA by default but it seems like you're going to reject every single rule as I'm opening them. What is your principled approach to WCAG to which I can hold you accountable? You're always very concerned with ROI but if we don't make decision we're wasting a lot of time in discussions.
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.
We settled on AA by default
@eps1lon I would add a distinction: we settled on it for the components. Did we discuss the documentation yet? I can't remember it. I think that, so far, we fixed issues on the documentation that were preventing correctly audit the accessibility of the components, but without having a strong focus on the documentation itself. I think that it deserves a different discussion because the incentives are not obviously identical. For the component, the motivation is that developers need it for the end-users and the organizations from legal perspectives.
I think that it's similar to the discussion about screenreaders support. We didn't talk about it initially, but later on, we said that we would support the most recent version of the most common screen readers, as well as document it in https://material-ui.com/getting-started/supported-platforms/. At least, from what I recall.
You're always very concerned with ROI but if we don't make a decision we're wasting a lot of time in discussions.
You are right, one of my concerns with WCAG is the return on investment. I think that there is a tradeoff to find between doing enough to be leading the field and not doing too much, sinking resources. My second concern is when it requires harming the UX of the majority of the people. So far, it felt that working on WCAG improved the UX most of the time. The cases where it goes against the UX of unimpaired users are not frequent. Sometimes it's by a small margin, like here. I think that we should be cautious when it's significant.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Accidentally dismissed my review. The unresolved conversation is not stale.
feedback taken into account
Shortcut CTRL + K for accessing search bar was added and issue with active element gets fixed.
Fixes #23804
https://deploy-preview-23959--material-ui.netlify.app/getting-started/installation/