-
-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Description
Describe the bug
type declaration in src/index.d.ts
export function useSelect(Options: {
defaultValue?: string | string[];
value?: string | string[];
multiple?: boolean;
search?: boolean;
options?: SelectSearchOption[];
onChange?: (
selectedValue: SelectedOptionValue | SelectedOptionValue[],
selectedOption: SelectedOption | SelectedOption[],
optionSnapshot: SelectSearchProps,
) => void;
getOptions?: (query: string) => Promise<SelectSearchOption[]>;
useFuzzySearch?: boolean;
filterOptions?: ((
options: SelectSearchOption[],
query: string,
) => SelectSearchOption[])[];
allowEmpty?: boolean;
closeOnSelect?: boolean;
closable?: boolean;
debounce?: number;
}): [
Snapshot,
{
tabIndex: string;
readOnly: boolean;
- onChange: (
- selectedValue: SelectedOptionValue | SelectedOptionValue[],
- selectedOption: SelectedOption | SelectedOption[],
- optionSnapshot: SelectSearchProps,
- ) => void;
disabled: boolean;
onMouseDown: (event: MouseEvent) => void;
onKeyDown: (event: KeyboardEvent) => void;
onKeyUp: (event: KeyboardEvent) => void;
onKeyPress: (event: KeyboardEvent) => void;
onBlur: () => void;
onFocus: () => void;
ref: MutableRefObject<any>;
},
but in src/useSelect.js
const valueProps = {
tabIndex: '0',
readOnly: !search,
placeholder,
value: focus && search ? q : snapshot.displayValue,
ref,
...keyHandlers,
onFocus: (e) => {
setFocus(true);
onFocus(e);
},
onBlur: (e) => {
setFocus(false);
setSearch('');
setHighlighted(-1);
onBlur(e);
},
onMouseDown: (e) => {
if (focus) {
e.preventDefault();
ref.current.blur();
}
},
+ onChange: search
+ ? ({ target }) => setSearch(target.value)
+ : null,
};
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
No labels