naive-ui icon indicating copy to clipboard operation
naive-ui copied to clipboard

fix: add proper tabindex when filterable

Open jaulz opened this issue 2 years ago β€’ 13 comments

Currently, when a Select is filterable you cannot reach the filter via tab control. This PR will add a proper tabindex to the inputs.

jaulz avatar Feb 03 '22 14:02 jaulz

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

πŸ” Inspect: https://vercel.com/tusimple/naive-ui/DBX6EhbUz9J8rrULW3nbJHneC7V6
βœ… Preview: https://naive-ui-git-fork-jaulz-fix-add-proper-tabindex-tusimple.vercel.app

vercel[bot] avatar Feb 03 '22 14:02 vercel[bot]

Codecov Report

Merging #2334 (dfeec06) into main (875b836) will decrease coverage by 0.01%. The diff coverage is 37.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2334      +/-   ##
==========================================
- Coverage   63.40%   63.39%   -0.02%     
==========================================
  Files         946      946              
  Lines       19261    19266       +5     
  Branches     4890     4893       +3     
==========================================
+ Hits        12212    12213       +1     
- Misses       5881     5885       +4     
  Partials     1168     1168              
Impacted Files Coverage Ξ”
src/_internal/selection/src/Selection.tsx 39.22% <37.50%> (-0.43%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update 875b836...dfeec06. Read the comment docs.

codecov[bot] avatar Feb 03 '22 14:02 codecov[bot]

You can open select by pressing enter if it's focused.

I make lazy focus intentionally. Is the behavior problematic?

07akioni avatar Feb 03 '22 15:02 07akioni

For normal selects it's fine but if the select is filterable I expect the input to be "tabbable" because I just want to type and select the input that matches my input. In my case I have a select that lets you pick your city from Google Places API. The options are requested on demand as the user types and there shouldn't be the possibility to enter free text.

jaulz avatar Feb 03 '22 15:02 jaulz

Can you rebase it? I want to see vercel preview.

07akioni avatar Feb 03 '22 15:02 07akioni

@07akioni here you go 😊

jaulz avatar Feb 03 '22 16:02 jaulz

Normal select's tab focusing is broken.

07akioni avatar Feb 03 '22 16:02 07akioni

Hm, what's not working for you? I can still focus the tab and press enter to open it.

jaulz avatar Feb 03 '22 16:02 jaulz

Tab focus this

image

07akioni avatar Feb 03 '22 19:02 07akioni

@07akioni sorry for the issue I missed that before. I think now it works fine and whenever a select is filterable you can tab properly and can start immediately typing.

jaulz avatar Feb 24 '22 09:02 jaulz

After esc is pressed in filterable select, the select box should still be focused.

image

I think maybe provide a prop to let user choose whether to focus input immediately is better.

07akioni avatar Feb 27 '22 13:02 07akioni

Okay, sure. Any suggestion for the name of the prop? 😊

jaulz avatar Mar 11 '22 09:03 jaulz

Okay, sure. Any suggestion for the name of the prop? 😊

Maybe focus-input-when-filterable? Not quite sure.

07akioni avatar Mar 15 '22 14:03 07akioni