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

fix: expose updatePositionStrategy prop for tooltip content #1026

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-gorillas-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

fix: expose `updatePositionStrategy` prop for tooltip content
1 change: 1 addition & 0 deletions packages/bits-ui/src/lib/bits/tooltip/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export type TooltipContentPropsWithoutHTML = WithChildNoChildrenSnippetProps<
| "arrowPadding"
| "sticky"
| "hideWhenDetached"
| "updatePositionStrategy"
| "dir"
> &
Omit<DismissibleLayerProps, "onInteractOutsideStart"> &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export type FloatingLayerContentProps = {

hideWhenDetached?: boolean;

/**
* "optimized" will only update the position when necessary, while "always"
* will update the position on each animation frame, which is useful if the floating
* content is following something like a mouse cursor.
*
* @defaultValue "optimized"
*/
updatePositionStrategy?: "optimized" | "always";

content?: Snippet<[{ props: Record<string, unknown>; wrapperProps: Record<string, unknown> }]>;
Expand Down
2 changes: 1 addition & 1 deletion sites/docs/src/routes/(main)/sink/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{/snippet}
</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Content>
<Tooltip.Content updatePositionStrategy="always">
<div class="tooltip-content">
{value[index]}
</div>
Expand Down