@streamscloud/kit 0.95.1 → 0.95.2

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.
@@ -17,7 +17,7 @@ const cancelTimers = () => {
17
17
  const scheduleOpen = () => {
18
18
  cancelTimers();
19
19
  openTimer = setTimeout(() => {
20
- popover?.open();
20
+ popover?.open({ moveFocus: false });
21
21
  openTimer = undefined;
22
22
  }, openDelay);
23
23
  };
@@ -29,12 +29,6 @@ const scheduleClose = () => {
29
29
  }, closeDelay);
30
30
  };
31
31
  const isInsideRoot = (node) => node instanceof Node && !!rootEl?.contains(node);
32
- // Without the zone check, Escape returning focus to the trigger reopens the popover.
33
- const handleFocusIn = (event) => {
34
- if (!isInsideRoot(event.relatedTarget)) {
35
- scheduleOpen();
36
- }
37
- };
38
32
  const handleFocusOut = (event) => {
39
33
  if (!isInsideRoot(event.relatedTarget)) {
40
34
  scheduleClose();
@@ -49,23 +43,16 @@ $effect(() => {
49
43
  });
50
44
  </script>
51
45
 
52
- <span
53
- bind:this={rootEl}
54
- class="hover-popover"
55
- role="presentation"
56
- onmouseenter={scheduleOpen}
57
- onmouseleave={scheduleClose}
58
- onfocusin={handleFocusIn}
59
- onfocusout={handleFocusOut}>
46
+ <span bind:this={rootEl} class="hover-popover" role="presentation" onmouseenter={scheduleOpen} onmouseleave={scheduleClose} onfocusout={handleFocusOut}>
60
47
  <Popover bind:this={popover} {...rest} />
61
48
  </span>
62
49
 
63
50
  <!--
64
51
  @component
65
- HoverPopover — thin wrapper around Popover that opens on hover/focus instead of click.
66
- Content is rendered as a DOM descendant of the wrapper, so moving the cursor from trigger
67
- to content stays "inside" the hover zone (no close fires). The `closeDelay` covers the
68
- small visual gap between trigger and content. A click on the trigger still toggles; nested in another popover's content it makes a submenu.
52
+ HoverPopover — thin wrapper around Popover that also opens on hover. Hover leaves focus where it is; from the keyboard the
53
+ trigger opens like a Popover's (Enter / Space toggles and moves focus into the content), and focus leaving the trigger and
54
+ content closes it. Content is a DOM descendant of the wrapper, so moving the cursor from trigger to content stays inside
55
+ the hover zone; `closeDelay` covers the gap between them. Nested in another popover's content it makes a submenu.
69
56
 
70
57
  `bind:this` on HoverPopover forwards `open() / close() / toggle()` from the inner Popover.
71
58
  -->
@@ -29,10 +29,10 @@ type Props = {
29
29
  closeDelay?: number;
30
30
  };
31
31
  /**
32
- * HoverPopover — thin wrapper around Popover that opens on hover/focus instead of click.
33
- * Content is rendered as a DOM descendant of the wrapper, so moving the cursor from trigger
34
- * to content stays "inside" the hover zone (no close fires). The `closeDelay` covers the
35
- * small visual gap between trigger and content. A click on the trigger still toggles; nested in another popover's content it makes a submenu.
32
+ * HoverPopover — thin wrapper around Popover that also opens on hover. Hover leaves focus where it is; from the keyboard the
33
+ * trigger opens like a Popover's (Enter / Space toggles and moves focus into the content), and focus leaving the trigger and
34
+ * content closes it. Content is a DOM descendant of the wrapper, so moving the cursor from trigger to content stays inside
35
+ * the hover zone; `closeDelay` covers the gap between them. Nested in another popover's content it makes a submenu.
36
36
  *
37
37
  * `bind:this` on HoverPopover forwards `open() / close() / toggle()` from the inner Popover.
38
38
  */
@@ -20,12 +20,14 @@ let backdropEl = $state.raw(undefined);
20
20
  let resolvedPlacement = $state(position);
21
21
  let previouslyFocused = null;
22
22
  let closedByEscape = false;
23
+ let moveFocusOnOpen = true;
23
24
  const openPopoverEntry = Symbol();
24
25
  /** Imperative API — bind:this on the component to access. */
25
- export const open = () => {
26
+ export const open = ({ moveFocus = true } = {}) => {
26
27
  if (disabled || opened) {
27
28
  return;
28
29
  }
30
+ moveFocusOnOpen = moveFocus;
29
31
  opened = true;
30
32
  on?.opened?.();
31
33
  };
@@ -112,7 +114,9 @@ $effect(() => {
112
114
  }
113
115
  previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
114
116
  closedByEscape = false;
115
- void focusFirstFocusable();
117
+ if (moveFocusOnOpen) {
118
+ void focusFirstFocusable();
119
+ }
116
120
  return () => {
117
121
  // Only Escape: returning focus on any close flashes the trigger's focus ring when a dialog opened from an item closes.
118
122
  if (closedByEscape) {
@@ -94,7 +94,9 @@ type Props = {
94
94
  * - `use:popoverIgnore={true}` action: block close for clicks anywhere in the marked sub-tree.
95
95
  */
96
96
  declare const Cmp: import("svelte").Component<Props, {
97
- /** Imperative API — bind:this on the component to access. */ open: () => void;
97
+ /** Imperative API — bind:this on the component to access. */ open: ({ moveFocus }?: {
98
+ moveFocus?: boolean;
99
+ }) => void;
98
100
  close: () => void;
99
101
  toggle: () => void;
100
102
  }, "">;
@@ -4,7 +4,10 @@ export { default as HoverPopover } from './cmp.hover-popover.svelte';
4
4
  export { popoverIgnore } from './popover-ignore';
5
5
  /** Imperative API exposed via `bind:this={instance}` on `<Popover>`. */
6
6
  export type PopoverInstance = {
7
- open: () => void;
7
+ /** `moveFocus: false` opens without focusing the first focusable in the content. */
8
+ open: (options?: {
9
+ moveFocus?: boolean;
10
+ }) => void;
8
11
  close: () => void;
9
12
  toggle: () => void;
10
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.95.1",
3
+ "version": "0.95.2",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",