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

Tooltip.Provider can't set defaults for most Tooltip.Root settings #872

Closed
pepkin88 opened this issue Nov 4, 2024 · 3 comments
Closed
Assignees
Labels
enhancement An improvement to an existing feature/component

Comments

@pepkin88
Copy link

pepkin88 commented Nov 4, 2024

Describe the bug

The documentation says, that "...[Tooltip.Provider] provides shared state for the tooltip components used within it". And then there is example with delayDuration and disableHoverableContent.

But is seems that those are the only props, that we can set defaults for, because all the other ones are auto-initialized in Root, and only nullish values can fall back to those set in the Provider.
So for example, if I want to have the value of disableCloseOnTriggerClick be read from the Provider, I can't do that, because if I then put <Tooltip.Root> without disableCloseOnTriggerClick prop, it would initialize to false and won't use the Provider's value.
I could work around it by setting those values on Root, but that'd defeat the purpose of having common settings in the Provider. I could also set those values to null, but that is not an accepted type for those fields.

This is the fragment in "tooltip/components/tooltip.svelte" that auto-initializes those values:

	let {
		open = $bindable(false),
		onOpenChange = noop,
		disabled = false,
		delayDuration,
		disableCloseOnTriggerClick = false,
		disableHoverableContent,
		ignoreNonKeyboardFocus = false,
		controlledOpen = false,
		children,
	}: TooltipRootProps = $props();

I think it's a mistake, because in "tooltip-provider.svelte" those props are exposed to be set as defaults.

Reproduction

https://stackblitz.com/edit/vitejs-vite-esq3cy?file=src%2FApp.svelte

Logs

No response

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 126.45 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - /usr/local/bin/node
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.9.0 - /usr/local/bin/pnpm
    bun: 1.0.14 - ~/.bun/bin/bun
  Browsers:
    Chrome: 130.0.6723.92
    Chrome Canary: 132.0.6817.0
    Safari: 17.5
    Safari Technology Preview: 18.0
  npmPackages:
    @sveltejs/kit: ^2.7.2 => 2.7.2
    bits-ui: 1.0.0-next.38 => 1.0.0-next.38
    svelte: ^5.1.0 => 5.1.0

Severity

annoyance

@pepkin88
Copy link
Author

pepkin88 commented Nov 4, 2024

BTW, I had to set interactOutsideBehavior="ignore" in Content, in order to be able to see the effect of disableCloseOnTriggerClick, because any pointerdown event on the trigger element would close the tooltip immediately.
Maybe the trigger element shouldn't be treated as something "outside"?

@huntabyte
Copy link
Owner

Looking into this!

@huntabyte huntabyte added the enhancement An improvement to an existing feature/component label Nov 5, 2024
@huntabyte huntabyte self-assigned this Nov 5, 2024
@huntabyte
Copy link
Owner

huntabyte commented Nov 5, 2024

Closed as fixed in bits-ui@1.0.0-next.44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement to an existing feature/component
Projects
None yet
Development

No branches or pull requests

2 participants