max-length support for searchable field
is there any way to pass max-length to searchable input field?
By wrapping components.Input in components prop adds max-length but somehow it requires two tabs to get out after selection to move to next element.
More importantly type of components.Input props (InputProps) does not include HTMLInputProps, so a lot of arguments need to be passed like:
const Input = useCallback((props: InputProps) =>
<components.Input {...props} {...extendedInputProps } aria-label={`label for ${ariaLabel || 'Select Dropdown'}`}/>
, []);
If we don' pass them like above, we get error as property does not exists on Input component.
I don't get why https://github.com/JedWatson/react-select/issues/1280 was close, can we please don't close this one ? I'm happy to submit a PR if you need help.
Hi @ruben0626, the author themselves closed the issue shortly after creating it, and has not since replied. We'll take a look at this issue in more detail when we can.
Greetings @ruben0626
A working solution to this is can be done by writing a custom Input component and leveraging the selectProps passed to it. All props passed to the Input are applied directly to the input element as attributes/props so this would be one approach.
const Input = props => {
const { maxLength } = props.selectProps;
return <components.Input {{...props }} maxLength={maxLength} />
}
const MySelect = props => <Select components={{Input}} maxLength={props.maxLength} ... />
This approach should work with any other props that you want to apply to the input as well (ie: required, readOnly, etc...)
If there are any other questions, please feel free to reply and we can reopen this.