@stnd/ui 0.7.3 → 0.8.0

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.
@@ -1,4 +1,5 @@
1
1
  <script>
2
+ import { tick } from "svelte";
2
3
  /**
3
4
  * @component AlertDialog
4
5
  * @description A native `<dialog>`-based confirmation modal. Used
@@ -26,12 +27,28 @@
26
27
  } = $props();
27
28
 
28
29
  let dialog = $state();
30
+ /** @type {Element | null} */
31
+ let opener = null;
29
32
 
30
33
  $effect(() => {
31
34
  if (open && dialog && !dialog.open) {
35
+ opener = document.activeElement;
32
36
  dialog.showModal();
33
37
  } else if (!open && dialog && dialog.open) {
34
38
  dialog.close();
39
+ // Hand focus back. A closed <dialog> is display:none, but the button
40
+ // the user just pressed stays `document.activeElement` — and this
41
+ // dialog swallows keydown (below), so until something else took focus
42
+ // every key, Escape and the app's shortcuts included, went to a hidden
43
+ // button and died there. `Dialog` restores focus; this one did not.
44
+ const back = opener;
45
+ opener = null;
46
+ tick().then(() => {
47
+ if (back?.isConnected) /** @type {HTMLElement} */ (back).focus?.();
48
+ // The opener may be disabled by now (a busy "Clear" button) and refuse
49
+ // focus; never leave it on the dialog we just closed.
50
+ if (dialog?.contains(document.activeElement)) /** @type {HTMLElement} */ (document.activeElement).blur();
51
+ });
35
52
  }
36
53
  });
37
54
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @stnd/ui
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Auto-bumped @stnd/ui due to modified code.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @stnd/icon@0.4.0
13
+
3
14
  ## 0.7.3
4
15
 
5
16
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stnd/ui",
3
- "version": "0.7.3",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "svelte": "./Combobox.svelte",
6
6
  "exports": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "wrangler": "^4.129.0",
33
- "@stnd/icon": "0.3.1",
33
+ "@stnd/icon": "0.4.0",
34
34
  "@stnd/store": "0.5.1",
35
35
  "@stnd/utils": "0.6.1"
36
36
  },