Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some bugs I spotted... #17

Open
barkin94 opened this issue Aug 2, 2020 · 1 comment
Open

Some bugs I spotted... #17

barkin94 opened this issue Aug 2, 2020 · 1 comment

Comments

@barkin94
Copy link

barkin94 commented Aug 2, 2020

  1. If hideSelectedOptions is set to true, all other options disappear after an option is selected. (Might be related to search functionality)
  2. If hideSelectedOptions is set to false, rfs-option-selected css class is applied to all options after an option is selected.
  3. onOptionChange does not fire again after an option is selected. Note that this was the case when hideSelectedOptions was set to false, since there is currently no way to fire it twice while it is set to true afaik.

Code is pretty much like the following. If my code is wrong, feel free to let me know.

const getOptionLabel = useCallback((option: SomeObject): string => option.text, []);
const onOptionChange = useCallback((option: SomeObject | null): void => {
	console.log(option);
	if (!option) return;
	setSomeState(prevState => {
		return { ...prevState, id: option.id };
	});
}, []);

<Select
	options={someObjectArray}
	isDisabled={!!someValue}
	ref={selectRef}
	placeholder="some text"
	onOptionChange={onOptionChange}
	getOptionLabel={getOptionLabel}
	addClassNames={true}
	hideSelectedOptions={true}
	menuItemSize={30}
	blurInputOnSelect={true}
	noOptionsMsg="some text"
	themeConfig={...}
        onMenuClose={() => selectRef.current.blur()}
/>
@based-ghost
Copy link
Owner

Ya good catch, not entirely sure yet, but I'm recreating it as well. I think it has to do with the fact that in a single-select, hideSelectedOptions=true scenario, when the menu is opened it tries to scroll to the index of that selected option (but it is not in the menuOptions result set). This issue is worked around in multi-select scenarios by always opening to the first item in the menuOptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants