@jsenv/navi 0.29.414 → 0.29.415
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/dist/dev/jsenv_navi.js +177 -50
- package/dist/dev/jsenv_navi.js.map +13 -11
- package/dist/jsenv_navi.js +170 -47
- package/dist/jsenv_navi.js.map +13 -11
- package/docs/autofocus.md +19 -0
- package/docs/route_transitions.md +17 -6
- package/package.json +1 -1
package/docs/autofocus.md
CHANGED
|
@@ -15,6 +15,7 @@ at the end of this page.
|
|
|
15
15
|
- [What a field says about itself](#what-a-field-says-about-itself)
|
|
16
16
|
- [When the opening places nothing](#when-the-opening-places-nothing)
|
|
17
17
|
- [The ring is decided too](#the-ring-is-decided-too)
|
|
18
|
+
- [When a popup closes](#when-a-popup-closes)
|
|
18
19
|
- [Moving the focus yourself](#moving-the-focus-yourself)
|
|
19
20
|
|
|
20
21
|
## What we want
|
|
@@ -202,6 +203,24 @@ focused while the input is). Style the standard name and you get that for free.
|
|
|
202
203
|
}
|
|
203
204
|
```
|
|
204
205
|
|
|
206
|
+
## When a popup closes
|
|
207
|
+
|
|
208
|
+
The focus goes back to what held it when the popup opened — the trigger, most
|
|
209
|
+
of the time — so the user carries on where they were.
|
|
210
|
+
|
|
211
|
+
A popup that closes because it **leaves the tree** — its component unmounted,
|
|
212
|
+
the page holding it left — gives the focus back once that change is over, and
|
|
213
|
+
only to an element still in the document: the trigger often leaves in the same
|
|
214
|
+
render, and focusing it just before it goes would be focusing nothing (and
|
|
215
|
+
making its removal cost more). It gives the focus back only into a void, too:
|
|
216
|
+
when something else took the focus meanwhile — the page arriving, focusing a
|
|
217
|
+
field of its own — that one keeps it.
|
|
218
|
+
|
|
219
|
+
So `{editing && <Dialog open>…</Dialog>}` unmounted from a button inside it
|
|
220
|
+
lands the focus back on the button that opened it, and a dialog left along
|
|
221
|
+
with the page around it lands it nowhere (`<body>`), exactly as if the page
|
|
222
|
+
had simply been removed.
|
|
223
|
+
|
|
205
224
|
## Moving the focus yourself
|
|
206
225
|
|
|
207
226
|
Prefer saying where the focus belongs over moving it: `autoFocus` on the field
|
|
@@ -567,6 +567,13 @@ What that means for a page and for the application around it:
|
|
|
567
567
|
is photographed on the old side only, leaves with its page, and is closed
|
|
568
568
|
when the page is taken down (see
|
|
569
569
|
[view_transitions.md](./view_transitions.md#a-hidden-element-is-not-photographed-even-in-the-top-layer)).
|
|
570
|
+
- **The focus it holds goes where its removal would have sent it** — to no
|
|
571
|
+
element — when it is hidden: a hidden element keeps the focus otherwise,
|
|
572
|
+
and would receive the keys pressed during the movement.
|
|
573
|
+
- **Never while a modal dialog is open.** An open modal keeps everything but
|
|
574
|
+
itself out of reach — the page arriving could not even take the focus — and
|
|
575
|
+
one in a page kept while leaving would stay open for the whole movement. The
|
|
576
|
+
page is then taken down at once, as without a movement.
|
|
570
577
|
- **Only where the page would have been taken down anyway.** A page rendered by
|
|
571
578
|
the same element on both sides — two routes, one component — is the same
|
|
572
579
|
instance carried over, as without a movement.
|
|
@@ -630,12 +637,16 @@ elements):
|
|
|
630
637
|
navi's movements declare nothing inheritable on the root; a custom type
|
|
631
638
|
publishing values of its own writes them on `::view-transition` (see
|
|
632
639
|
[Custom movements](#custom-movements)).
|
|
633
|
-
- **The page being left reacting to the
|
|
634
|
-
component in it that re-renders on
|
|
635
|
-
callback, next to the page arriving being built
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
640
|
+
- **The page being left reacting to what the navigation changed.** Every
|
|
641
|
+
component in it that re-renders on the change does so inside the update
|
|
642
|
+
callback, next to the page arriving being built. A link or a button pointing
|
|
643
|
+
at a route (`<Link route>`, `<Button route>`) reads one flag — whether it is
|
|
644
|
+
current — and stays still unless that flips: a profile opening leaves the
|
|
645
|
+
links to a hundred other profiles exactly as they were (on the list of
|
|
646
|
+
thirty cards: 90 re-renders gone, first frame 58 → 41 ms). What else reacts
|
|
647
|
+
is worth keeping to what has to — measured: every card of the page being
|
|
648
|
+
left re-rendering when the page arriving loads its own games into the store
|
|
649
|
+
the cards read theirs from.
|
|
639
650
|
- **Re-rendering what did not change, on the press itself.** A component that
|
|
640
651
|
only wants a yes or a no reads a computed flag, not the signal it is derived
|
|
641
652
|
from: a list whose rows each read the count of runs in flight re-rendered
|