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

How to avoid onSelectedItemChange running clicking on Item in combobox? #1637

Open
tetianaman opened this issue Feb 5, 2025 · 0 comments
Open

Comments

@tetianaman
Copy link

tetianaman commented Feb 5, 2025

I want to click at the pencil icon and execute handleIconClick only, but onSelectedItemChange runs also and e.nativeEvent.preventDownshiftDefault = true; doesn't help. How can I prevent running the onSelectedItemChange?

Image
export const CustomItemRenderer = forwardRef<...>((props, ref) => {
        const handleIconClick = (e) => {
            console.log('item handleEditClick');
            e.nativeEvent.preventDownshiftDefault = true;
        };

        return (
            <div ref={ref} {...props} >
                <div>{item.title}</div>
                <IconButton onClick={handleIconClick} />
            </div>
        );
});
export const Autocomplete = (...) => {
        ...
        const { ... } = useCombobox({
            ...
            onSelectedItemChange({ selectedItem }) {
                console.log('autocomplete onSelectedItemChange');
            },
        });
        ...
};

Console:
item handleEditClick
autocomplete onSelectedItemChange

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

1 participant