Repository navigation
Commit 13b8981
authored
fix(Selector): the selected row stays on the trigger as the list grows (#10062)
* chore(core): the layer runtime's exit copy, for a touch presentation's close
placeLayerExitCopy puts a static, inert copy of a closing layer where the
layer was drawn, in the top layer, for a touch presentation's close to play
on: the browser hides a popover the moment it closes. The copy keeps the
layer's box, transform, presented look, overflow and scroll positions; has
no ids, anchor names, form names or form owner; is inert and hidden from assistive
technology; and its descendants' keyframe animations and transitions do not
start again. A refused show during the closing toggle waits, hidden, until
the toggle is over. A layer inside other layers gets its copy after the
outermost one, with what it inherited there (its color scheme included),
so a close that takes the layers around it too still draws the copy. That
copy is shown again above the copy the same close then places for a layer
around it. A layer has one copy. The layer-runtime record states
it, and that the presentation plays its exit on the copy (AST-094 FR7).
Core's shared inertCopy now takes every copied native control and
form-associated custom element out of any form with form="", as its
documentation says, so the swap's copies join no form either. It also
sets anchor-name: none on each copied element that has an anchor name, so
no live anchor gets a second element.
* feat(Layer): one input hold, first used by Dialog, Drawer and MobileNav (spec:AST-094 FR35)
Layer/inputHold holds a layer's pointer input while its presentation
enters or leaves. holdInput(layer, {until, scope}) raises a shield:
'viewport' over the whole viewport while a modal layer enters; 'surface'
over the layer's own box while a non-modal one enters, the page around it
live; 'layer' over the viewport, its content inert, while a layer leaves.
It decides by each event's pointer (a finger's or a pen's press is held to
its end; a mouse passes once it moves with no button down, or from the
start when the page last heard a mouse, DEC-16), never cancels a touch's
start, and cancels a one-finger move so a pinch still zooms (FR10). It
hears input through Core's shared input stream before every other
subscriber, and ends the dispatch for a held event, so press feedback and the
gesture host never hear it; the stream gains first subscribers and records
the type of the latest pointer event it delivers (getLastPointerType). The gesture
host asks the hold for each touch (holdsTouch), so the hold imports nothing
from gestures/ and a component in the root entry may use it statically
(architecture:react-component-runtime INV13).
Its first users hold only under a coarse primary pointer, a touch
presentation (FR13): Dialog, Drawer and MobileNav hold a finger's tap or
drag while they enter (holdEntranceInput, which reads the entrance's own
animations; MobileNav's slide-in is capped at 550 ms), a non-modal Drawer
only on its panel. Under a fine primary pointer nothing is held and
nothing listens (FR24). Where the primary pointer is fine and the screen
also takes touch, a finger is not held yet; AST-094's current-state impact
and Drawer's record name that gap. AST-094's current-state impact also
names the first press of a still mouse after a finger, which lands on an
entering presentation's shield. AlertDialog renders Dialog, so its
entrance is held too: its record says FR7 ships in part, the leaving
alert's inert content waiting for FR6's dismissal.
Every browser proof lands its input at an exact point (an entrance held
where it is, the page's clock, or an exact step of a drag) and plays once.
The WebKit interaction lane's scope includes Layer/inputHold.ts: the
gesture host imports it, so the gesture specs' fixture bundles it.
MobileNav's record states what the rest of the slide-out after the close
does: it is inert, taking no input and hidden from assistive technology
(FR5). A browser case proves both against the open drawer.
From #8342 and its per-event offer, #8630 (Dialog and Drawer) and #8374
(MobileNav).
Co-authored-by: Cindy Zhang <cindyxz@meta.com>
* feat(Popover): under a finger, it grows out of its trigger and shrinks back into it
Under a coarse primary pointer, Popover grows out of its trigger on the
theme's entrance duration and easing and shrinks back into it on the
theme's exit duration and easing, on the layer runtime's exit copy. A fine
primary pointer keeps the layer's own entrance.
* test(Popover): browser proofs of the touch presentation's grow and shrink
Real-browser proofs, in Chromium and WebKit, that under a finger Popover
grows out of its trigger on the theme's entrance tokens and shrinks back on
its exit tokens, keeps advancing through a blocked main thread, does no
Layout or Paint per frame, and cross-fades under Reduce Motion, with
storyboards of both.
* Merge #8342 fbe71df (the shared input hold) into the Popover touch presentation (#9823), as #8223's base
* fix(Popover): under a finger, a tap during the presentation is ignored, as on iOS
While the popover grows out of its trigger under a coarse primary pointer,
the layer runtime's input hold takes every touch. A tap outside neither
dismisses it nor reaches what is under it, a pan scrolls nothing, and a
pinch still zooms the page.
* perf(Popover): the touch presentation starts in the next frame
Opening a popover under a finger ran the touch presentation in the
opening task. The animator's style writes and the box reads laid the
anchored page out more often than a mouse opening does, and on a
loaded machine that task could pass the 50 ms long-task line.
The opening task now reads and writes nothing while it runs. As it
ends, after its own reads, the layer's CSS entrance goes off, a write
that costs it no layout. A style read after that task then starts no
entrance. The presentation waits for the next animation frame, which
runs before it paints. There it puts the element invisible at its
full size, reads the boxes, starts the curves and takes the input
hold. A close before that frame cancels it and leaves the element as
the component styles it, with no compositing layer. A presentation
again during a dismissal still starts at once, since it reads
nothing. Without animation frames, the presentation runs at once and
a close plays the shrink.
Popover's record notes, under Current-state impact, that the input
hold starts on the first frame after the open, so a touch landing
within that frame reaches the page.
* chore(core): the layer runtime's exit copy, for a touch presentation's close
placeLayerExitCopy puts a static, inert copy of a closing layer where the
layer was drawn, in the top layer, for a touch presentation's close to play
on: the browser hides a popover the moment it closes. The copy keeps the
layer's box, transform, presented look, overflow and scroll positions; has
no ids, anchor names, form names or form owner; is inert and hidden from assistive
technology; and its descendants' keyframe animations and transitions do not
start again. A refused show during the closing toggle waits, hidden, until
the toggle is over. A layer inside other layers gets its copy after the
outermost one, with what it inherited there (its color scheme included),
so a close that takes the layers around it too still draws the copy. That
copy is shown again above the copy the same close then places for a layer
around it. A layer has one copy. The layer-runtime record states
it, and that the presentation plays its exit on the copy (AST-094 FR7).
Core's shared inertCopy now takes every copied native control and
form-associated custom element out of any form with form="", as its
documentation says, so the swap's copies join no form either. It also
sets anchor-name: none on each copied element that has an anchor name, so
no live anchor gets a second element.
* Merge branch 'main' into uikit/c26-layer-exit-copy
* feat(Popover): under a finger, it grows out of its trigger and shrinks back into it
Under a coarse primary pointer, Popover grows out of its trigger on the
theme duration step nearest iOS's growth (`--duration-medium-min`) and the
theme's entrance easing, and shrinks back into it on the theme's exit
duration and easing, on the layer runtime's exit copy. A fine primary
pointer keeps the layer's own entrance.
* test(Popover): browser proofs of the touch presentation's grow and shrink
Real-browser proofs, in Chromium and WebKit, that under a finger Popover
grows out of its trigger on the theme's entrance tokens and shrinks back on
its exit tokens, keeps advancing through a blocked main thread, does no
Layout or Paint per frame, and cross-fades under Reduce Motion, with
storyboards of both.
* Merge the updated #9823 into the Popover presentation hold (tree matches the lane's intended resolution)
* Merge the updated #8223 into the Popover next-frame presentation (frame scheduling kept, createMotionEngine)
* Merge branch 'main' into uikit/c26-layer-exit-copy
* Merge the updated lower stack branch into uikit/c26-popover-present (own diff unchanged)
* Merge the updated lower stack branch into uikit/c27-popover-present-proofs (own diff unchanged)
* Merge the updated lower stack branch into uikit/c26-popover-presentation-hold (own diff unchanged)
* Merge the updated lower stack branch into uikit/c26-popover-present-next-frame (own diff unchanged)
* Merge #8187's input hold into the Popover touch proofs
* feat(Popover): a touch during the growth is ignored
While the popover grows, the layer runtime's input hold takes every touch,
as UIKit ignores touches while it presents a popover. A tap outside does not
dismiss it and reaches nothing under it, and a pinch still zooms the page.
This folds in the hold that #8223 carried, so the growth and its hold land
together.
* test(Popover): browser proofs of the hold while the popover grows
A tap outside, a tap on the trigger and a pan while the popover grows do
nothing, a pinch still zooms, and a storyboard shows the growth going on
under a tap outside. Folded from #8223.
* docs(AST-094): Popover's input hold starts on the frame after the open
AST-094's current-state line for Popover now states the window its
Popover record already states: the input hold starts on the first frame
after the open, so a touch that lands within that frame reaches the
page. Starting the hold at the open would lay the page out twice in
the opening task.
Two comments now say that the layer's CSS entrance goes off in a
microtask, once the script that opened the popover returns.
* fix(core): the exit copy keeps no closed layer
The exit copy found the inner layers to raise through a module-level
set of every copied layer. A layer React removed on close stayed
reachable there until a later close showed a copy. The inner layers
are inside the closing layer, so they are now found there, and
nothing keeps a layer once it is gone.
Chromium 150 and later refuse a show during another popover's toggle,
so the copy can open in the next frame. The browser spec's
light-dismiss case now reads the copy after a frame, as its
nested-close cases do. The cap check's comment now names only the
copy cap.
* docs(core): the exit copy's JSDoc states the empty-canvas rule once
The empty-canvas rule stays in the first paragraph, and the inert-copy
paragraph no longer repeats it or `inertCopy`'s own contract.
* Merge the updated lower stack branch into uikit/c26-popover-present (own diff unchanged)
* Merge the updated lower stack branch into uikit/c27-popover-present-proofs (own diff unchanged)
* Merge the folded #9823 into the Popover next-frame presentation (#8223 absorbed into #8187)
* test(Popover): time the rendering proof from each motion's start
The growth now starts in a frame callback. Where the compositor starts
it in that frame, its animation starts at the frame's time, before the
animate() call the logger stamped. The presentation's window then ended
less than 20 ms before the growth did, and it could reach the one-off
work at the growth's end. The logger now records each call and the
animation's own start time. A wait still finds its animation by the
call, which always follows the key press, and times its window from
the start.
* test(Popover): the blocked-main-thread proof blocks from the page and asserts the verdict
The page now starts the block once the growth has run a frame, and the
proof asserts the harness verdict, which fails a judged part under 4
frames. Here the growth runs 600 ms at a constant speed, so each frame
moves several pixels and a block that starts late on a loaded machine
still lands inside it.
* Merge the updated lower stack branch into uikit/c26-popover-present-next-frame (own diff unchanged)
* fix(Selector): the overlay clamps in layout, so the keyboard cap and every reader of the layer's box see it
The selected-item overlay realized its viewport clamp as a negative margin
on the anchored layer, which anchor positioning's fit check swallowed, so a
list opened near the viewport's end lay past it. A translate instead hid the
clamp from every layout reader: the software keyboard's cap read the layer's
untransformed box, and a same-size move painted a stale frame.
The overlay's layer now takes no position fallbacks (an internal layer option,
off by default) and clamps in layout: `inset-block-start` places the selected
row's center on the anchor's center between the viewport's gutters, and
`inset-inline-start` starts the layer at its anchor's own start inside the
inline gutters, from three private variables the Selector sets (the row's
offset in the list, and the layer's block and inline sizes). A move or a
scroll re-places the list in the same layout, so no frame paints a stale
place; content and selection re-measure on the layer's resettle watcher and
commit synchronously.
Tests: every overlay case asserts a usable list (at least two rows in full
view, or every row), the move case asserts no stale painted frame, the
keyboard case asserts two rows above the keyboard line, and a cross-engine
spec checks the clamp in Chromium and WebKit in both directions, a list wider
than its trigger and a list taller than the room included. A story places a
Selector near the viewport's end beside a text input.
* refactor(Selector): drop the overlay layer that never flips
The owners ruled that every anchored placement can flip, so the overlay
layer's internal no-fallback option, its layer-runtime paragraph and the
Selector FR2 rewrite go. This restores every file of this change to its
base. On main, the layer's end gutter already keeps the list inside the
viewport.
* Merge main
* fix(Selector): the selected row stays on the trigger as options grow
The selected-item overlay measured its margin once, when the list
opened. An option that grew above the selection while the list was open
left the row off the trigger, and a list near the viewport's end grew
past it. The browser then flipped the layer above its anchor, where the
margin moved the list the wrong way.
The overlay now measures again when the open listbox resizes, through
the shared resize observer, and commits before the frame paints. On a
layer flipped above its anchor, the margin sets the same clamped top
from the anchor's top.
* fix(Selector): read the overlay's flip safely, skip the first report
An engine with the Popover API but no CSS anchor positioning has no
positionArea on its computed style, so the overlay threw on every open
there. It now reads getPropertyValue('position-area'), which gives an
empty string in such an engine.
observeResize reports once at registration, inside the commit that
opens the list, where React cannot flush and warns. That report is now
skipped, since the measuring Effect already runs in that commit.
A list at its height cap does not resize when an option grows, so the
changeset now claims the fix only for a list shorter than its cap.
* test(Selector): drop a stray comment and an unused helper parameter
The growth spec carried a doc comment that documented no declaration,
and a prepare parameter on openPreSelected that no case passed. Both
go, and no proof changes.
* docs(Selector): say plainly why the first resize report is skipped
The comment on the open list's resize observation ended in the passive
"so it is skipped". It now leads with the action and keeps the reason.
* Merge main
* refactor(Selector): observe the open list with observeResizeAfterLayout
The shared resize observer now has observeResizeAfterLayout (#9810). It
observes an element without the report observeResize makes when it
registers. The open list's observer skipped that report by hand, so it
now uses the helper, as useTruncation does. No other shared-observer
subscriber watches the list, so the helper's microtask report never
runs, and the list behaves as before.
* Merge main
* fix(Selector): keep a flipped list above the software keyboard
The margin for a list the browser flipped above its trigger had no
keyboard term. Beside a field near the viewport's end, the list stayed
under a software keyboard. The flipped margin now keeps the list's end
above the keyboard, and its top on screen.
That margin applies only where it would not also fit below the anchor.
Where it would, the browser moves the layer back below, and a flipped
margin there would squeeze the list. There the overlay keeps main's
margin.
Two SelectorKeyboardInset cases fix the field 8 px above the viewport's
end, with the keyboard up before the open and rising while the list is
open. A story sets a field 300 px above the screen's end for a phone
check, and a browser spec pins it beside a 291 px keyboard.
* fix(Selector): shrink a tall list above the software keyboard
A list taller than the room above a software keyboard, beside a field
near the viewport's end, stayed under the keyboard. The flipped margin
stopped the list's top at 0, with no room for the layer's gutter. So
the browser dropped that position, and the runtime caps no layer above
its trigger.
At the open, the overlay now always takes the margin below the anchor,
as main does. That margin fits below the anchor, so the browser opens
the layer there, and the runtime caps it above a keyboard. Only a layer
that the browser flips while the list is open gets the flipped margin,
because the browser keeps that side. Its top stays below the gutter.
Two SelectorKeyboardInset cases open the nine-option story at 844x390
beside a 200 px keyboard, up before the open and rising while the list
is open.
* fix(Selector): read the layer's gutter from the margin it keeps
The overlay read the layer's gutter as the larger of its two block
margins. A flip swaps them, so that read could take the overlay's own
margin: with a keyboard up, 270 px. A flipped list that grew again then
stopped at that floor, past the keyboard's line.
The gutter is now the margin that the overlay does not set: the
block-end margin below the anchor, and the block-start margin above it.
The unit case for a flipped layer's gutter now also names the flip in
the layer's position area.
A SelectorKeyboardInset case flips the list with a grown option, raises
a keyboard, and grows another option.
* Merge main
* test(Selector): raise the keyboard story's trigger above Safari's bars
With the keyboard up, an iPhone tap on a trigger just above Safari's
bottom bars closed the keyboard and opened nothing, and the keyboard
story's trigger sat there. The story now lays out its Selector as
Overlay Beside Keyboard does, so its trigger sits at the same height.
The browser spec now fixes the field 300 px above the viewport's end
itself, so it still pins the same case.
* Merge main
* Merge main
* Merge main
* docs(Selector): record the Android landscape evidence gap
FR2's verification row now names the case no emulator scene can set
up: Android landscape with the keyboard up leaves 67 px visible and
40 px of scroll, at this head and on main alike.1 parent 86b0733 commit 13b8981
8 files changed
Lines changed: 826 additions & 20 deletions
File tree
- .changeset
- apps/storybook/stories
- docs/specs/components/Selector
- packages/core/src/Selector
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1137 | 1137 | | |
1138 | 1138 | | |
1139 | 1139 | | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1140 | 1184 | | |
1141 | 1185 | | |
1142 | 1186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
649 | | - | |
650 | | - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
651 | 655 | | |
652 | 656 | | |
653 | | - | |
| 657 | + | |
654 | 658 | | |
655 | | - | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
656 | 662 | | |
657 | 663 | | |
658 | 664 | | |
| |||
663 | 669 | | |
664 | 670 | | |
665 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
666 | 679 | | |
667 | 680 | | |
668 | 681 | | |
| |||
864 | 877 | | |
865 | 878 | | |
866 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
867 | 903 | | |
868 | 904 | | |
869 | 905 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
0 commit comments