Skip to content

Commit

Permalink
fix(tooltip): overriding floating styles when forceVisible true (melt…
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolzak authored and lolcabanon committed Apr 20, 2024
1 parent aa06df1 commit 780ced0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-weeks-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@melt-ui/svelte': patch
---

Tooltip: fixed bug where tooltip content style gets reset when forceVisible is true and $open gets updated #1010
9 changes: 4 additions & 5 deletions src/lib/builders/tooltip/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
pointInPolygon,
styleToString,
toWritableStores,
removeUndefined,
sleep,
portalAttr,
} from '$lib/internal/helpers/index.js';
Expand Down Expand Up @@ -198,17 +199,15 @@ export function createTooltip(props?: CreateTooltipProps) {
const content = makeElement(name('content'), {
stores: [isVisible, open, portal, ids.content],
returned: ([$isVisible, $open, $portal, $contentId]) => {
return {
return removeUndefined({
role: 'tooltip',
hidden: $isVisible ? undefined : true,
tabindex: -1,
style: styleToString({
display: $isVisible ? undefined : 'none',
}),
style: $isVisible ? undefined : styleToString({ display: 'none' }),
id: $contentId,
'data-portal': portalAttr($portal),
'data-state': $open ? 'open' : 'closed',
};
});
},
action: (node: HTMLElement): MeltActionReturn<TooltipEvents['content']> => {
let unsubFloating = noop;
Expand Down

0 comments on commit 780ced0

Please sign in to comment.