@jsenv/navi 0.29.414 → 0.29.416
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 +220 -55
- package/dist/dev/jsenv_navi.js.map +15 -13
- package/dist/jsenv_navi.js +213 -52
- package/dist/jsenv_navi.js.map +15 -13
- package/docs/autofocus.md +19 -0
- package/docs/resource.md +7 -3
- package/docs/route_transitions.md +20 -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
|
package/docs/resource.md
CHANGED
|
@@ -292,9 +292,13 @@ Keep their **ids**, not the objects: an object is a snapshot, and it stops
|
|
|
292
292
|
following its row the moment anything writes to it. `RESOURCE.useAllByIds(ids)`
|
|
293
293
|
reads those rows as they are now — a kept id turned back into something that
|
|
294
294
|
stays fresh, and the ids the store no longer holds simply drop out.
|
|
295
|
-
`RESOURCE.useById(id)` is the singular, `RESOURCE.useArray()` the whole store
|
|
296
|
-
|
|
297
|
-
|
|
295
|
+
`RESOURCE.useById(id)` is the singular, `RESOURCE.useArray()` the whole store.
|
|
296
|
+
None is a hook (a `.map()` over them is fine), and each subscribes the render
|
|
297
|
+
that calls it to what it returns: `useById` and `useAllByIds` to the rows they
|
|
298
|
+
hand back — a card reading its own row stays still while other rows of the
|
|
299
|
+
store are written, and re-renders when its row is — `useArray` to the whole
|
|
300
|
+
store. An entry of `useAllByIds` given by a unique key rather than by id can
|
|
301
|
+
only be found by reading the whole store, and that read follows it too.
|
|
298
302
|
|
|
299
303
|
## Relations: pick one of the four methods
|
|
300
304
|
|
|
@@ -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,19 @@ 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). A row read with
|
|
647
|
+
`RESOURCE.useById` follows that row only, so the page arriving loading rows
|
|
648
|
+
of its own into the same store leaves the cards of the page being left as
|
|
649
|
+
they were. What reacts is then the page's own reading of its route's action
|
|
650
|
+
— its params, its data and its state all move as the route stops matching —
|
|
651
|
+
and that re-renders the page with everything in it (on the list of thirty
|
|
652
|
+
cards: about 1,150 component renders, the largest share of the callback).
|
|
639
653
|
- **Re-rendering what did not change, on the press itself.** A component that
|
|
640
654
|
only wants a yes or a no reads a computed flag, not the signal it is derived
|
|
641
655
|
from: a list whose rows each read the count of runs in flight re-rendered
|