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

[docs] Add a shortcut to access the search bar #23959

Merged
merged 4 commits into from Dec 15, 2020

Conversation

hmaddisb
Copy link
Contributor

@hmaddisb hmaddisb commented Dec 11, 2020

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/

Capture d’écran 2020-12-14 à 23 28 27

@mui-pr-bot
Copy link

mui-pr-bot commented Dec 11, 2020

No bundle size changes

Generated by 🚫 dangerJS against 5de2cd3

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Dec 12, 2020
@oliviertassinari oliviertassinari removed their assignment Dec 12, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 12, 2020

@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>
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

@eps1lon eps1lon Dec 13, 2020

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 /, no CTRL+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, no CTRL+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"

Copy link
Member

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?

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

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).

Comment on lines 151 to 154
const matchKey =
((nativeEvent.ctrlKey || nativeEvent.metaKey) && nativeEvent.key === 'k') ||
nativeEvent.key === '/' ||
nativeEvent.key === 's';
Copy link
Member

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).

Copy link
Member

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.

Copy link
Member

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:

  1. We ignore it.
  2. We only handle the keyboard shortcut when body and main are focused.
  3. We add .defaultMuiPrevented to signal that the event was already handled.
  4. Else?

I'm happy with any of these, maybe a slight preference for 2 as a quick win. Thoughts?

Copy link
Member

@eps1lon eps1lon Dec 15, 2020

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.

Copy link
Member

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.

@mbrookes

This comment has been minimized.

@oliviertassinari

This comment has been minimized.

@mbrookes

This comment has been minimized.

Copy link
Member

@eps1lon eps1lon left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs] Add a shortcut to access the search bar
5 participants