@lostgradient/cinder 0.24.1 → 0.24.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.
- package/CHANGELOG.md +6 -0
- package/components.json +1 -1
- package/dist/components/selection-popover/index.js +4 -2
- package/dist/index.js +4 -2
- package/dist/server/components/selection-popover/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/{index.server-c71m0a88.js → index.server-0yrz8ryn.js} +3 -2
- package/package.json +1 -1
- package/src/components/selection-popover/selection-popover.svelte +24 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lostgradient/cinder
|
|
2
2
|
|
|
3
|
+
## 0.24.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8c3065a`](https://github.com/stevekinney/cinder/commit/8c3065a5889811bc3315e3a7fcbfa1bfc816b62c) Thanks [@stevekinney](https://github.com/stevekinney)! - Keep SelectionPopover's pre-open focus owner for the popover's whole open lifetime so an Escape that follows a cancel or submit still returns focus to it instead of dropping it on `<body>`.
|
|
8
|
+
|
|
3
9
|
## 0.24.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/components.json
CHANGED
|
@@ -3720,9 +3720,10 @@ function Selection_popover($$anchor, $$props) {
|
|
|
3720
3720
|
}
|
|
3721
3721
|
function restoreFocus(preventScroll = true) {
|
|
3722
3722
|
const target = restoreFocusElement;
|
|
3723
|
-
restoreFocusElement = null;
|
|
3724
3723
|
if (!target)
|
|
3725
3724
|
return;
|
|
3725
|
+
if (document.activeElement === target)
|
|
3726
|
+
return;
|
|
3726
3727
|
isRestoringFocus = true;
|
|
3727
3728
|
target.focus({ preventScroll });
|
|
3728
3729
|
isRestoringFocus = false;
|
|
@@ -3807,6 +3808,7 @@ function Selection_popover($$anchor, $$props) {
|
|
|
3807
3808
|
$6.set(expanded, false);
|
|
3808
3809
|
$6.set(commentBody, "");
|
|
3809
3810
|
restoreFocus();
|
|
3811
|
+
restoreFocusElement = null;
|
|
3810
3812
|
}
|
|
3811
3813
|
return;
|
|
3812
3814
|
}
|
|
@@ -3878,4 +3880,4 @@ export {
|
|
|
3878
3880
|
Selection_popover as SelectionPopover
|
|
3879
3881
|
};
|
|
3880
3882
|
|
|
3881
|
-
//# debugId=
|
|
3883
|
+
//# debugId=0D22F90112A8785E64756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -61140,9 +61140,10 @@ function Selection_popover($$anchor, $$props) {
|
|
|
61140
61140
|
}
|
|
61141
61141
|
function restoreFocus(preventScroll = true) {
|
|
61142
61142
|
const target = restoreFocusElement;
|
|
61143
|
-
restoreFocusElement = null;
|
|
61144
61143
|
if (!target)
|
|
61145
61144
|
return;
|
|
61145
|
+
if (document.activeElement === target)
|
|
61146
|
+
return;
|
|
61146
61147
|
isRestoringFocus = true;
|
|
61147
61148
|
target.focus({ preventScroll });
|
|
61148
61149
|
isRestoringFocus = false;
|
|
@@ -61227,6 +61228,7 @@ function Selection_popover($$anchor, $$props) {
|
|
|
61227
61228
|
$266.set(expanded, false);
|
|
61228
61229
|
$266.set(commentBody, "");
|
|
61229
61230
|
restoreFocus();
|
|
61231
|
+
restoreFocusElement = null;
|
|
61230
61232
|
}
|
|
61231
61233
|
return;
|
|
61232
61234
|
}
|
|
@@ -72875,4 +72877,4 @@ export {
|
|
|
72875
72877
|
AccessGateExport as AccessGate
|
|
72876
72878
|
};
|
|
72877
72879
|
|
|
72878
|
-
//# debugId=
|
|
72880
|
+
//# debugId=DEEC3443656D929B64756E2164756E21
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Selection_popover,
|
|
3
3
|
selection_popover_default
|
|
4
|
-
} from "../../index.server-
|
|
4
|
+
} from "../../index.server-0yrz8ryn.js";
|
|
5
5
|
import"../../index.server-grq89cv5.js";
|
|
6
6
|
import"../../index.server-s4pfz6pb.js";
|
|
7
7
|
import"../../index.server-mf4dr1kp.js";
|
package/dist/server/index.js
CHANGED
|
@@ -84,9 +84,10 @@ function Selection_popover($$renderer, $$props) {
|
|
|
84
84
|
}
|
|
85
85
|
function restoreFocus(preventScroll = true) {
|
|
86
86
|
const target = restoreFocusElement;
|
|
87
|
-
restoreFocusElement = null;
|
|
88
87
|
if (!target)
|
|
89
88
|
return;
|
|
89
|
+
if (document.activeElement === target)
|
|
90
|
+
return;
|
|
90
91
|
isRestoringFocus = true;
|
|
91
92
|
target.focus({ preventScroll });
|
|
92
93
|
isRestoringFocus = false;
|
|
@@ -195,4 +196,4 @@ function Selection_popover($$renderer, $$props) {
|
|
|
195
196
|
var selection_popover_default = Selection_popover;
|
|
196
197
|
export { Selection_popover, selection_popover_default };
|
|
197
198
|
|
|
198
|
-
//# debugId=
|
|
199
|
+
//# debugId=A16C2C54A73CE48364756E2164756E21
|
package/package.json
CHANGED
|
@@ -94,15 +94,31 @@ function rememberFocus() {
|
|
|
94
94
|
const activeElement = document.activeElement;
|
|
95
95
|
restoreFocusElement = activeElement instanceof HTMLElement ? activeElement : null;
|
|
96
96
|
}
|
|
97
|
+
// The remembered element describes "what had focus before this popover
|
|
98
|
+
// opened", which stays true for the popover's whole open lifetime — not just
|
|
99
|
+
// until the first restore. Keeping the reference here (rather than spending
|
|
100
|
+
// it) is what lets a second restore work: expand -> cancel restores once
|
|
101
|
+
// while the popover stays open, and a later Escape must restore again
|
|
102
|
+
// instead of dropping focus on <body> (issue #1269). The reference is
|
|
103
|
+
// released where the `wasOpen` latch resets, so the next open re-arms it,
|
|
104
|
+
// and by onFocusMovedOutside once the user genuinely moves on.
|
|
97
105
|
function restoreFocus(preventScroll = true) {
|
|
98
106
|
const target = restoreFocusElement;
|
|
99
|
-
restoreFocusElement = null;
|
|
100
107
|
if (!target)
|
|
101
108
|
return;
|
|
109
|
+
// Focus is already where it belongs, so there is nothing to restore. Now
|
|
110
|
+
// that the reference outlives the first restore, this is what keeps an
|
|
111
|
+
// external close following an internal cancel/submit from driving focus
|
|
112
|
+
// onto the same element a second time.
|
|
113
|
+
if (document.activeElement === target)
|
|
114
|
+
return;
|
|
102
115
|
// .focus() dispatches `focusin` synchronously, and the window-level
|
|
103
116
|
// ownership-tracking listener below can't otherwise tell this
|
|
104
117
|
// component-driven restoration apart from the user genuinely moving on
|
|
105
118
|
// to something outside the popover. Flag it so that listener exempts it.
|
|
119
|
+
// Load-bearing now that the reference outlives the restore: without the
|
|
120
|
+
// exemption, restoring to the (outside-the-popover) pre-open owner would
|
|
121
|
+
// trip onFocusMovedOutside and clear the very reference we are keeping.
|
|
106
122
|
isRestoringFocus = true;
|
|
107
123
|
target.focus({ preventScroll });
|
|
108
124
|
isRestoringFocus = false;
|
|
@@ -206,10 +222,14 @@ $effect(() => {
|
|
|
206
222
|
wasOpen = false;
|
|
207
223
|
expanded = false;
|
|
208
224
|
commentBody = '';
|
|
209
|
-
// Return focus to wherever it was before the popover opened
|
|
210
|
-
//
|
|
211
|
-
//
|
|
225
|
+
// Return focus to wherever it was before the popover opened, then
|
|
226
|
+
// release the reference: this open session is over, so the next open
|
|
227
|
+
// must re-arm from whatever has focus then rather than reuse a stale
|
|
228
|
+
// element. restoreFocus() null-guards and no-ops when the target
|
|
229
|
+
// already has focus, so an internal close that already restored does
|
|
230
|
+
// not drive focus a second time.
|
|
212
231
|
restoreFocus();
|
|
232
|
+
restoreFocusElement = null;
|
|
213
233
|
}
|
|
214
234
|
return;
|
|
215
235
|
}
|