downshift icon indicating copy to clipboard operation
downshift copied to clipboard

fix: align useCombobox getToggleButtonProps type with useSelect

Open drewbrend opened this issue 5 months ago • 1 comments

What:

Allow comboboxes to have a toggle button of any element type in TypeScript (not just an HTMLButtonElement)

Why:

useCombobox's getToggleButtonProps was only compatible with HTMLButtonElement

useSelect is compatible with any HTMLElement

This is related to my previous PR: https://github.com/downshift-js/downshift/pull/1486

I am now upgrading our repo to downshift V8 and noticed that this is fixed for selects, however comboboxes are still locked to using a button by this type.

How:

I simply changed HTMLButtonElement to HTMLElement to match select's behaviour.

I am not familiar enough with these types to say for sure, but it seems like we could simply align UseSelectGetToggleButtonPropsOptions with this UseComboboxGetToggleButtonPropsOptions? The only difference after this PR is that UseComboboxGetToggleButtonPropsOptions also has a disabled prop (through GetToggleButtonPropsOptions). Are implementations using useSelect able to disable the toggle button? If so, I think these could be simplified to use a shared type.

Checklist:

  • [ ] Documentation
  • [ ] Tests
  • [x] TypeScript Types
  • [ ] Flow Types
  • [ ] Ready to be merged

drewbrend avatar Jan 30 '24 21:01 drewbrend

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (a5d6310) 100.00% compared to head (b21d159) 100.00%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1568   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        18           
  Lines         1738      1738           
  Branches       522       522           
=========================================
  Hits          1738      1738           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jan 30 '24 21:01 codecov-commenter