Skip to content

Commit fb3ceb2

Browse files
committed
fix(show): fix initial positioning of tooltip using show
1 parent 9075d6e commit fb3ceb2

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/action-tooltip.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125
if (component) {
126126
component.$destroy();
127127
component = null;
128+
visible = false;
129+
show = false;
128130
}
129131
});
130132
@@ -141,8 +143,8 @@
141143
142144
$: isComponent = typeof content === 'object';
143145
$: tooltipRef && show
144-
? setTimeout(() => (visible = true), animationDelay)
145-
: setTimeout(() => (visible = false), animationDelay);
146+
? setTimeout(() => (visible = true), 0)
147+
: (visible = false);
146148
</script>
147149

148150
{#if content}

src/action.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const tooltip = (element, props) => {
66
let action = props?.action || element.getAttribute('action') || 'hover';
77

88
const detect = ({ target }) => {
9-
if (target && !target.classList.contains('tooltip')) {
9+
if (config.hideOnClickOutside && target && !target.classList.contains('tooltip')) {
1010
onHide();
1111
}
1212
};
@@ -24,8 +24,7 @@ export const tooltip = (element, props) => {
2424
const onClick = () => {
2525
if (component) {
2626
if (
27-
action !== 'click' ||
28-
(action === 'click' && !config.hideOnClickOutside)
27+
!(action === 'click' && config.hideOnClickOutside)
2928
) {
3029
onHide();
3130
}

src/tooltip.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
// @ts-ignore
8686
const detect = ({ target }) => {
8787
if (
88+
hideOnClickOutside &&
8889
containerRef !== target &&
8990
tooltipRef !== target &&
9091
// @ts-ignore

0 commit comments

Comments
 (0)