tbleckert / react-select-search

⚡️ Lightweight select component for React
https://react-select-search.com
MIT License
676 stars 149 forks source link

Select on space key, not enter #109

Closed optislav closed 3 years ago

optislav commented 3 years ago

Very good library, but I need to select option without submitting a form. Is there way I can replace enter key to space key?

davidangel commented 3 years ago

I had this same issue and solved it by intercepting theonKeyPress event in a styled component wrapper:

    <StyledSelectSearchWrapper
      onKeyPress={e => {
        e.key === 'Enter' && e.preventDefault();
      }}
    >
      <ReactSelectSearch ... />
    </StyledSelectSearchWrapper>