bits-ui 2.15.2 → 2.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -39,7 +39,23 @@
|
|
|
39
39
|
onCloseAutoFocus: boxWith(() => onCloseAutoFocus),
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
const mergedProps = $derived(
|
|
42
|
+
const mergedProps = $derived(
|
|
43
|
+
mergeProps(restProps, contentState.props, {
|
|
44
|
+
side,
|
|
45
|
+
sideOffset,
|
|
46
|
+
align,
|
|
47
|
+
onOpenAutoFocus,
|
|
48
|
+
isValidEvent,
|
|
49
|
+
trapFocus,
|
|
50
|
+
loop,
|
|
51
|
+
id,
|
|
52
|
+
ref: contentState.opts.ref,
|
|
53
|
+
preventScroll,
|
|
54
|
+
onInteractOutside: handleInteractOutside,
|
|
55
|
+
onEscapeKeydown: handleEscapeKeydown,
|
|
56
|
+
shouldRender: contentState.shouldRender,
|
|
57
|
+
})
|
|
58
|
+
);
|
|
43
59
|
|
|
44
60
|
function handleInteractOutside(e: PointerEvent) {
|
|
45
61
|
onInteractOutside(e);
|
|
@@ -76,20 +92,7 @@
|
|
|
76
92
|
<PopperLayerForceMount
|
|
77
93
|
{...mergedProps}
|
|
78
94
|
{...contentState.popperProps}
|
|
79
|
-
ref={contentState.opts.ref}
|
|
80
|
-
{side}
|
|
81
|
-
{sideOffset}
|
|
82
|
-
{align}
|
|
83
95
|
enabled={contentState.parentMenu.opts.open.current}
|
|
84
|
-
{preventScroll}
|
|
85
|
-
onInteractOutside={handleInteractOutside}
|
|
86
|
-
onEscapeKeydown={handleEscapeKeydown}
|
|
87
|
-
{onOpenAutoFocus}
|
|
88
|
-
{isValidEvent}
|
|
89
|
-
{trapFocus}
|
|
90
|
-
{loop}
|
|
91
|
-
{id}
|
|
92
|
-
shouldRender={contentState.shouldRender}
|
|
93
96
|
>
|
|
94
97
|
{#snippet popper({ props, wrapperProps })}
|
|
95
98
|
{@const finalProps = mergeProps(props, {
|
|
@@ -110,20 +113,7 @@
|
|
|
110
113
|
<PopperLayer
|
|
111
114
|
{...mergedProps}
|
|
112
115
|
{...contentState.popperProps}
|
|
113
|
-
ref={contentState.opts.ref}
|
|
114
|
-
side="right"
|
|
115
|
-
sideOffset={2}
|
|
116
|
-
align="start"
|
|
117
116
|
open={contentState.parentMenu.opts.open.current}
|
|
118
|
-
{preventScroll}
|
|
119
|
-
onInteractOutside={handleInteractOutside}
|
|
120
|
-
onEscapeKeydown={handleEscapeKeydown}
|
|
121
|
-
{onOpenAutoFocus}
|
|
122
|
-
{isValidEvent}
|
|
123
|
-
{trapFocus}
|
|
124
|
-
{loop}
|
|
125
|
-
{id}
|
|
126
|
-
shouldRender={contentState.shouldRender}
|
|
127
117
|
>
|
|
128
118
|
{#snippet popper({ props, wrapperProps })}
|
|
129
119
|
{@const finalProps = mergeProps(props, {
|
|
@@ -19,6 +19,7 @@ export declare class PopoverRootState {
|
|
|
19
19
|
overlayPresence: PresenceManager;
|
|
20
20
|
openedViaHover: boolean;
|
|
21
21
|
hasInteractedWithContent: boolean;
|
|
22
|
+
hoverCooldown: boolean;
|
|
22
23
|
closeDelay: number;
|
|
23
24
|
constructor(opts: PopoverRootStateOpts);
|
|
24
25
|
setDomContext(ctx: DOMContext): void;
|
|
@@ -24,6 +24,7 @@ export class PopoverRootState {
|
|
|
24
24
|
// hover tracking state
|
|
25
25
|
openedViaHover = $state(false);
|
|
26
26
|
hasInteractedWithContent = $state(false);
|
|
27
|
+
hoverCooldown = $state(false);
|
|
27
28
|
closeDelay = $state(0);
|
|
28
29
|
#closeTimeout = null;
|
|
29
30
|
#domContext = null;
|
|
@@ -159,7 +160,7 @@ export class PopoverTriggerState {
|
|
|
159
160
|
this.#isHovering = true;
|
|
160
161
|
this.#clearCloseTimeout();
|
|
161
162
|
this.root.cancelDelayedClose();
|
|
162
|
-
if (this.root.opts.open.current)
|
|
163
|
+
if (this.root.opts.open.current || this.root.hoverCooldown)
|
|
163
164
|
return;
|
|
164
165
|
const delay = this.opts.openDelay.current;
|
|
165
166
|
if (delay <= 0) {
|
|
@@ -181,6 +182,7 @@ export class PopoverTriggerState {
|
|
|
181
182
|
return;
|
|
182
183
|
this.#isHovering = false;
|
|
183
184
|
this.#clearOpenTimeout();
|
|
185
|
+
this.root.hoverCooldown = false;
|
|
184
186
|
// let GraceArea handle the close - it will call handleHoverClose via onPointerExit
|
|
185
187
|
// we just need to stop any pending open timer
|
|
186
188
|
}
|
|
@@ -196,6 +198,15 @@ export class PopoverTriggerState {
|
|
|
196
198
|
this.root.hasInteractedWithContent = true;
|
|
197
199
|
return;
|
|
198
200
|
}
|
|
201
|
+
// if closing while hovering with openOnHover enabled, set cooldown to prevent
|
|
202
|
+
// immediate re-open via hover
|
|
203
|
+
if (this.#isHovering && this.opts.openOnHover.current && this.root.opts.open.current) {
|
|
204
|
+
this.root.hoverCooldown = true;
|
|
205
|
+
}
|
|
206
|
+
// if clicking to open while in cooldown, reset cooldown (explicit open)
|
|
207
|
+
if (this.root.hoverCooldown && !this.root.opts.open.current) {
|
|
208
|
+
this.root.hoverCooldown = false;
|
|
209
|
+
}
|
|
199
210
|
this.root.toggleOpen();
|
|
200
211
|
}
|
|
201
212
|
onkeydown(e) {
|