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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve search/clear a11y #281

Merged
merged 5 commits into from Mar 12, 2019

Conversation

nolanlawson
Copy link

@nolanlawson nolanlawson commented Mar 9, 2019

Fixes the issues described in #221:

  1. Adds a new i18n.clear value (default of "Clear") as the accessible label for the clear button
  2. To give the clear button a focus style, avoid making it disabled when the search is focused. Otherwise when you press tab, it doesn't change focus to the clear button. (Rather than disabling it, I made it so that if you somehow click the button while searching, it just does nothing.) ignore, I was wrong about this
  3. Tweak the styles on the clear button to give it more padding, so that the outline appears nicer-looking. As an added bonus, this improves the touch target size for the button, although for the best a11y, it really should be at least 44x44 pixels (right now it's 23x19).

Visually the button should look exactly the same when not focused. When it is focused, it will use the user agent default stylesheet (in my case, Ubuntu orange):

out

I also made some other a11y fixes in the same part of the code:

  1. Adds a <label> to the <input> because a placeholder is not enough for a11y.
  2. Change <input type="text"> to <input type="search">, because that's what it is. 馃檪 To fix issues with user agent styles adding their own "search" style, I added -webkit-appearance: none;.

nolanlawson added a commit to nolanlawson/emoji-mart that referenced this pull request Mar 10, 2019
@nolanlawson
Copy link
Author

OK, I tweaked and fixed up some issues with the clear button. I kept the original behavior where it's only enabled when there is some search text.

I also added a small tweak where, when you search, focus is returned back to the input field. This means you can

  1. Type some text
  2. Press tab to focus on the clear button
  3. Press spacebar to click the button
  4. The input text is cleared, and the focus is back on the search input

nolanlawson added a commit to nolanlawson/emoji-mart that referenced this pull request Mar 10, 2019
nolanlawson added a commit to nolanlawson/emoji-mart that referenced this pull request Mar 10, 2019
@nolanlawson nolanlawson merged commit 445d2d4 into missive:master Mar 12, 2019
@nolanlawson nolanlawson mentioned this pull request Mar 12, 2019
5 tasks
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.

None yet

1 participant