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

Tootip. Stucks after selecting an option from Select if wrapped around Select component #1089

Open
zzzorgo opened this issue Nov 3, 2023 · 2 comments

Comments

@zzzorgo
Copy link
Contributor

zzzorgo commented Nov 3, 2023

Expected behaviour: tooltip is only shown while hovered
Actual behaviour: tooltip appears after selecting an option from a list

Minimal example:

        <Tooltip content={'Stuck tooltip'}>
            <Select>
                {[1, 2, 3, 4].map((num) => (
                    <Select.Option
                        key={num}
                        value={num.toString()}
                        content={
                            <Tooltip content={num}>
                                <span>{num}</span>
                            </Tooltip>
                        }
                    />
                ))}
            </Select>
        </Tooltip>
Screen.Recording.2023-11-03.at.11.14.35.mov
@zzzorgo
Copy link
Contributor Author

zzzorgo commented Nov 3, 2023

On the second thought, it looks like I should disable showing tooltip "on click" for clickable components, but I don't see such option in the tooltip props. Probably the issue could be resolved by providing such a prop.

@amje
Copy link
Contributor

amje commented Jan 10, 2024

@zzzorgo Tooltip works as a expected, shown on hover/focus. The problem is the Select focuses the control back on closing. You can workaround this manually, using contolled open state for Select and disable Tooltip when it's opened:

const [open, setOpen] = React.useState(false);

<Tooltip content={'Tooltip'} disabled={open}>
    <Select open={open} onOpenChange={setOpen}>
        {[1, 2, 3, 4].map((num) => (
            <Select.Option
                key={num}
                value={num.toString()}
            />
        ))}
    </Select>
</Tooltip>

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