diff --git a/docs/architecture/react-component-runtime.md b/docs/architecture/react-component-runtime.md index 2fdca4e244aeb..ed3a5032a17f9 100644 --- a/docs/architecture/react-component-runtime.md +++ b/docs/architecture/react-component-runtime.md @@ -197,9 +197,15 @@ those contracts. shared internal hook in the keyboard module (`packages/core/src/keyboard/`) measures the on-screen keyboard, keeps the page from panning on focus, and dismisses the keyboard when a surface moves (`spec:AST-099`); it is not - exported. The keyboard height and each keyboard change's transition (start - time, resting value, curve) reach styles only as the hook's value and live - only in the hook: each consumer applies them through a StyleX functional style + exported. Apps read its value, read-only, from the public keyboard entry, and + Lab reads it from Core's internal keyboard entry (`spec:AST-099` FR3): the + height, whether a keyboard is up, and whether it has settled, with a + notification when it settles. The keyboard height + and each keyboard change's transition (start + time, resting value, curve) reach styles only as the hook's value, or as a + Core host's read-only layout value that includes the keyboard's lift + (`spec:AST-099` FR3), and live nowhere else: each consumer applies them + through a StyleX functional style on its own element, and no CSS custom property on the document root or a shared ancestor carries them. The keyboard module may also write, and remove, a CSS `translate` on the nearest fixed-position ancestor of a focused Core @@ -236,9 +242,10 @@ those contracts. the hook makes at most one layout read per keyboard change. A component outside Core does not ride; it commits the resting value once. Packages outside Core cannot import the hook; a component there that responds to the - keyboard keeps one listener that measures as `spec:AST-099` FR2 defines, keeps - focus from panning as FR4 does, blurs as FR5 does, applies the height through - a functional style on its own elements, and follows INV3 and INV5. The hook + keyboard reads the hook's value through its entry and keeps no listener of its + own that measures the keyboard. It keeps focus from panning as + `spec:AST-099` FR4 does, blurs as FR5 does, applies the height through a + functional style on its own elements, and follows INV3 and INV5. The hook follows INV3 and INV5. - **INV12 — Size changes inside a container have one module.** In `@astryxdesign/core`, one internal module produces the size-change glide @@ -674,24 +681,24 @@ observable-behavior predicates require review or runtime evidence. Likewise, a focused test proves only its named behavior and mutation expectation; a green component suite is not blanket conformance with every invariant. -| Invariant | Evidence | Failure signal | -| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| INV1–INV2 | Initial-render and interaction tests | Output flashes a known-wrong state, or one action is delayed or repeated through an Effect | -| INV3, INV5 | StrictMode setup/cleanup and dependency-change tests | Duplicate callback, leaked work, stale subscription, or missing resynchronization | -| INV3 (ref sync) | `pnpm review:pre` item j flags an Effect that only copies a value into a ref; review accepts a latest-value ref only through `useCommittedRef` or `useCommittedRefInto`, read in an event or gesture callback, never during render or in `useMemo`. Item j also flags a committed ref read during render or in `useMemo`, with tests in `scripts/lib/pre-review-findings.test.mjs` | A per-site Effect or render-time write that keeps a latest-value ref in place of `useCommittedRef`, or a read of one during render or in `useMemo` | -| INV1, INV4, INV6 | Ref attach/null/replacement, DOM-in-state rejection, and old-node cleanup-before-new-attach mutations | A DOM node or collection enters state, old node remains active, cleanup misses replacement, or ref mutation changes semantics silently | -| INV7 | Real-browser geometry plus N-consumer observer-instance/subscription mutations | Geometry is invalid, observer instances grow with repeated consumers, one unsubscribe silences peers, or cleanup removes another subscriber | -| INV8 | Owner-observable behavior across documented composition replacement; optional focused internal mechanism tests | Behavior disappears or changes owner when a documented subpart is replaced | -| INV9 | Provider/external-store identity and render-count tests | Unchanged semantic payload changes identity, or snapshot identity creates a render loop | -| INV10 | Shared test over every adopter of the announcement module | An adopter holding its own Effect, observer, timer, or listener for its own-content announcement | -| INV11 | Source boundary check plus hook tests across StrictMode replay and unmount | A second keyboard listener or measurement in Core; a consumer reading a CSS custom property on the root or a shared ancestor for the height; an export of the hook; a component outside Core measuring by a rule other than AST-099 FR2, or riding the keyboard; a listener left after unmount; a translate left on an app element after the keyboard hides once focus has left the field, or after the field unmounts; any other write on an app element; a translate on a container whose layout box is not at the bottom edge, that fills the viewport, or whose own `translate` is not `none`; a translate on a container whose position the app is animating with CSS when the module measures; on a docked container too tall to fit above the keyboard once moved (a full-height side drawer, a pane below a fixed header), a translate when a scroller holds the field or one larger than the focused field needs to clear the keyboard; a translate measured before the page's own keyboard listeners run; a covered field deciding its keyboard behavior in an Effect that reacts to focus; a Core rider driven by JavaScript per frame or by its own transition; or more than one layout read per keyboard change beyond the docked bar's one read INV11 names | -| INV12 | Source boundary check plus real-browser tests on a throttled phone profile over a 10-level by 50-sibling tree and two changes in one frame | A per-frame height or layout, a walk past the area or into a subtree other than `display: contents`, an element moved twice for one frame, an added element other than a swap's one transient copy, that copy left after the swap ends, an exported reporting function, a slide that moves a child outside the band, or a moving clip on an element whose parts slide fails | -| INV13 | Source boundary check plus bundle analysis of a page with several touch components, and real-browser tests on a throttled phone profile, under a fine pointer, and on a hybrid device | A second copy of a touch module on one page, a component bundling its own copy of a module's primitive, an `import()` whose target is one of these modules, other than `Item`'s released loader for its deprecated swipe props, a swipe module (the gesture core, the animator, the panels' rendering, the row's gesture code) imported by `Item` or `ListItem`, swipe code in `Item` other than its deprecated path (that loader, the released row style, the role gate, the `commit` warning, the bridge, the click guard, the event forwarders, and the coexistence diagnostic), or any of it outside the deprecated path, a public export or doc entry for the modules, an install call or installed check in the public API, a gesture listener in a component that uses no gesture, or an idle document listener outside a press other than the one shared press controller and the one stray-click swallower, an import of `@astryxdesign/core/internal/*` outside Core and Lab, a class outside the recognizer family, an `instanceof` check on a recognizer, an internal factory with a public factory's name, or a direct module import for a job the public layer covers fails | -| INV15 | Unit tests of the animator's value mode and real-browser proofs of its adopters | A value off its channels' timing (the theme's tokens for a program-started change, a spring only where `spec:AST-094` FR45 keeps one), a count past the component's swap size, a count or cross-fade under reduced motion with a coarse or a fine pointer, an intermediate value announced, or a public export fails | -| INV16 | Review of each Core component that handles a concern Core owns in a shared hook or utility | A Core component that keeps its own effect, listener, or tracker for that concern fails, whether or not it also calls the hook or utility | -| INV16 (slot presence) | `no-nullish-jsx-guard` strict lint over Core and RichText, with no baseline, and `no-truthy-jsx-guard` strict lint over Core, with no baseline; both catch inline guards only, so review also checks for a presence test hoisted into a variable, converted (`!!value`, `Boolean(value)`), made by an early return or a `??` default, or passed through a prop spread, which the lints pass; empty-slot tests that pass `''`, `false`, `true`, and `null` and compare with an omitted slot, plus `0` as content, in Item, MetadataList, ChatSystemMessage, TreeList, TopNavMegaMenu, RichTextEditor, and RichTextEditorToolbar | A slot given `''`, `true`, or `false` draws a wrapper, lane, border, or separator that an omitted slot does not, an element loses the name it has without the slot, `0` does not render, or a new bare nullish or truthiness presence test, inline or hoisted, a truthiness guard past the baseline, a baseline entry added, or a hand-written copy of the check lands | -| INV17 | Review of every `ref.current` assignment reached during render, plus StrictMode double-render tests where a ref feeds later behavior. `pnpm review:pre` item j flags an added render-time ref write, except lazy initialization and the exceptions this record names, with tests in `scripts/lib/pre-review-findings.test.mjs`; `useTableSortable`'s config ref is exempt as this invariant's named gap until the owner decides | A `ref.current` write in a component or hook body outside a lazy one-time initialization or an exception INV17 names, or behavior outside those exceptions that reads a value written by a render React discarded | -| INV18 | Review of every added read that forces layout: `getBoundingClientRect`, `getClientRects`, `offset*`, `client*`, `scroll*` (`scrollTop`, `scrollHeight`, and the rest), `inner*` and `outer*`, `visualViewport` geometry, and `getComputedStyle` (evidence gap: no automated finding yet) | A layout read in a per-frame, scroll or resize path that no current clause requires there, a read interleaved with writes, a read without a comment that names its reason, more than one measurement pass per change beyond the before-and-after pair a current clause requires, or JavaScript measurement where CSS placement serves | -| INV18 reorder | Browser tests of a mouse drag in a reorderable List while a wheel scrolls its scroller: one checks the preview, the drop line and the drop, and one traces layout and counts the offset reads | A wheel scroll mid-drag that leaves the drop line or the preview off the pointer, a drop away from the pointer, a layout the read forces, or more than one read in a scrolled frame | -| INV18 (after layout) | `sharedResizeObserver.test.ts` cases for `observeResizeAfterLayout`, and the Chromium trace test that opens a Lightbox gallery on a clamped caption and counts its layouts | A first read in the registration-time call, a first read before the browser's own first notification after layout, or a layout that the caption's first read forces | -| INV19 | A size check over Core component folders: each non-test behavior module over 300 lines or 3 KB gzip names its shared engine, or its record names why none fits | A private behavior module over the threshold with no shared engine and no recorded reason | +| Invariant | Evidence | Failure signal | +| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| INV1–INV2 | Initial-render and interaction tests | Output flashes a known-wrong state, or one action is delayed or repeated through an Effect | +| INV3, INV5 | StrictMode setup/cleanup and dependency-change tests | Duplicate callback, leaked work, stale subscription, or missing resynchronization | +| INV3 (ref sync) | `pnpm review:pre` item j flags an Effect that only copies a value into a ref; review accepts a latest-value ref only through `useCommittedRef` or `useCommittedRefInto`, read in an event or gesture callback, never during render or in `useMemo`. Item j also flags a committed ref read during render or in `useMemo`, with tests in `scripts/lib/pre-review-findings.test.mjs` | A per-site Effect or render-time write that keeps a latest-value ref in place of `useCommittedRef`, or a read of one during render or in `useMemo` | +| INV1, INV4, INV6 | Ref attach/null/replacement, DOM-in-state rejection, and old-node cleanup-before-new-attach mutations | A DOM node or collection enters state, old node remains active, cleanup misses replacement, or ref mutation changes semantics silently | +| INV7 | Real-browser geometry plus N-consumer observer-instance/subscription mutations | Geometry is invalid, observer instances grow with repeated consumers, one unsubscribe silences peers, or cleanup removes another subscriber | +| INV8 | Owner-observable behavior across documented composition replacement; optional focused internal mechanism tests | Behavior disappears or changes owner when a documented subpart is replaced | +| INV9 | Provider/external-store identity and render-count tests | Unchanged semantic payload changes identity, or snapshot identity creates a render loop | +| INV10 | Shared test over every adopter of the announcement module | An adopter holding its own Effect, observer, timer, or listener for its own-content announcement | +| INV11 | Source boundary check plus hook tests across StrictMode replay and unmount | A second keyboard listener or measurement in Core; a consumer reading a CSS custom property on the root or a shared ancestor for the height; an export of the hook; a component outside Core with a keyboard listener or a measurement of its own, or riding the keyboard; a listener left after unmount; a translate left on an app element after the keyboard hides once focus has left the field, or after the field unmounts; any other write on an app element; a translate on a container whose layout box is not at the bottom edge, that fills the viewport, or whose own `translate` is not `none`; a translate on a container whose position the app is animating with CSS when the module measures; on a docked container too tall to fit above the keyboard once moved (a full-height side drawer, a pane below a fixed header), a translate when a scroller holds the field or one larger than the focused field needs to clear the keyboard; a translate measured before the page's own keyboard listeners run; a covered field deciding its keyboard behavior in an Effect that reacts to focus; a Core rider driven by JavaScript per frame or by its own transition; or more than one layout read per keyboard change beyond the docked bar's one read INV11 names | +| INV12 | Source boundary check plus real-browser tests on a throttled phone profile over a 10-level by 50-sibling tree and two changes in one frame | A per-frame height or layout, a walk past the area or into a subtree other than `display: contents`, an element moved twice for one frame, an added element other than a swap's one transient copy, that copy left after the swap ends, an exported reporting function, a slide that moves a child outside the band, or a moving clip on an element whose parts slide fails | +| INV13 | Source boundary check plus bundle analysis of a page with several touch components, and real-browser tests on a throttled phone profile, under a fine pointer, and on a hybrid device | A second copy of a touch module on one page, a component bundling its own copy of a module's primitive, an `import()` whose target is one of these modules, other than `Item`'s released loader for its deprecated swipe props, a swipe module (the gesture core, the animator, the panels' rendering, the row's gesture code) imported by `Item` or `ListItem`, swipe code in `Item` other than its deprecated path (that loader, the released row style, the role gate, the `commit` warning, the bridge, the click guard, the event forwarders, and the coexistence diagnostic), or any of it outside the deprecated path, a public export or doc entry for the modules, an install call or installed check in the public API, a gesture listener in a component that uses no gesture, or an idle document listener outside a press other than the one shared press controller and the one stray-click swallower, an import of `@astryxdesign/core/internal/*` outside Core and Lab, a class outside the recognizer family, an `instanceof` check on a recognizer, an internal factory with a public factory's name, or a direct module import for a job the public layer covers fails | +| INV15 | Unit tests of the animator's value mode and real-browser proofs of its adopters | A value off its channels' timing (the theme's tokens for a program-started change, a spring only where `spec:AST-094` FR45 keeps one), a count past the component's swap size, a count or cross-fade under reduced motion with a coarse or a fine pointer, an intermediate value announced, or a public export fails | +| INV16 | Review of each Core component that handles a concern Core owns in a shared hook or utility | A Core component that keeps its own effect, listener, or tracker for that concern fails, whether or not it also calls the hook or utility | +| INV16 (slot presence) | `no-nullish-jsx-guard` strict lint over Core and RichText, with no baseline, and `no-truthy-jsx-guard` strict lint over Core, with no baseline; both catch inline guards only, so review also checks for a presence test hoisted into a variable, converted (`!!value`, `Boolean(value)`), made by an early return or a `??` default, or passed through a prop spread, which the lints pass; empty-slot tests that pass `''`, `false`, `true`, and `null` and compare with an omitted slot, plus `0` as content, in Item, MetadataList, ChatSystemMessage, TreeList, TopNavMegaMenu, RichTextEditor, and RichTextEditorToolbar | A slot given `''`, `true`, or `false` draws a wrapper, lane, border, or separator that an omitted slot does not, an element loses the name it has without the slot, `0` does not render, or a new bare nullish or truthiness presence test, inline or hoisted, a truthiness guard past the baseline, a baseline entry added, or a hand-written copy of the check lands | +| INV17 | Review of every `ref.current` assignment reached during render, plus StrictMode double-render tests where a ref feeds later behavior. `pnpm review:pre` item j flags an added render-time ref write, except lazy initialization and the exceptions this record names, with tests in `scripts/lib/pre-review-findings.test.mjs`; `useTableSortable`'s config ref is exempt as this invariant's named gap until the owner decides | A `ref.current` write in a component or hook body outside a lazy one-time initialization or an exception INV17 names, or behavior outside those exceptions that reads a value written by a render React discarded | +| INV18 | Review of every added read that forces layout: `getBoundingClientRect`, `getClientRects`, `offset*`, `client*`, `scroll*` (`scrollTop`, `scrollHeight`, and the rest), `inner*` and `outer*`, `visualViewport` geometry, and `getComputedStyle` (evidence gap: no automated finding yet) | A layout read in a per-frame, scroll or resize path that no current clause requires there, a read interleaved with writes, a read without a comment that names its reason, more than one measurement pass per change beyond the before-and-after pair a current clause requires, or JavaScript measurement where CSS placement serves | +| INV18 reorder | Browser tests of a mouse drag in a reorderable List while a wheel scrolls its scroller: one checks the preview, the drop line and the drop, and one traces layout and counts the offset reads | A wheel scroll mid-drag that leaves the drop line or the preview off the pointer, a drop away from the pointer, a layout the read forces, or more than one read in a scrolled frame | +| INV18 (after layout) | `sharedResizeObserver.test.ts` cases for `observeResizeAfterLayout`, and the Chromium trace test that opens a Lightbox gallery on a clamped caption and counts its layouts | A first read in the registration-time call, a first read before the browser's own first notification after layout, or a layout that the caption's first read forces | +| INV19 | A size check over Core component folders: each non-test behavior module over 300 lines or 3 KB gzip names its shared engine, or its record names why none fits | A private behavior module over the threshold with no shared engine and no recorded reason | diff --git a/docs/specs/AST-094-touch-presentations/spec.md b/docs/specs/AST-094-touch-presentations/spec.md index f4de42ca5c505..82d130af87560 100644 --- a/docs/specs/AST-094-touch-presentations/spec.md +++ b/docs/specs/AST-094-touch-presentations/spec.md @@ -548,10 +548,14 @@ a measured, sourced difference exists. that gesture's click (DEC-17). A recognizer that begins MUST claim its touches by cancelling `touchmove` through a non-passive listener on its element; a watcher, which never claims, is exempt (DEC-7). A `touchmove` of a touch no recognizer owns MUST NOT be cancelled, with - five exceptions. While a scroll lock under a modal presentation holds the + six exceptions. While a scroll lock under a modal presentation holds the page, it MAY cancel the moves of a one-finger touch that no recognizer owns when that pan would scroll the page; a second finger is never cancelled - (FR10), and the page keeps pinch-zoom. A modal overlay that takes the page + (FR10), and the page keeps pinch-zoom. While a software keyboard is up, a + container that rides it MAY hold the page through the same page hold: it + cancels the moves of a one-finger touch that starts on the container and + that no recognizer owns, unless a scroller inside the container takes that + pan or the page is pinch-zoomed (`spec:AST-099` FR4). A modal overlay that takes the page scroll lock also stops the page's pull-to-refresh and overscroll bounce while it holds the lock, and releases them with it. Once its press is delivered, a @@ -1134,7 +1138,7 @@ Motion that FR45 moves, by component. Each component's record carries its own li | FR13 | Resolver unit tests and a server-render test | coarse and fine pointer; narrow, wide and short; server render; hydrating render | a component that answers the conditions differently, or a touch presentation in the server or hydrating render, fails | | FR14 | Browser tests of a sheet over a scrolled list | scrolled and at its top | a midway handoff fails | | FR15–FR17 | Recognizer unit tests on synthetic streams with explicit timestamps | exclusive, simultaneous, require-to-fail, nested; a watcher beside a claiming winner; a blocked main thread; a pan at 10 pt per axis | a wrong winner, a late deadline, or a translation that keeps the hysteresis, or a watcher failed or cancelled by a claiming winner fails | -| FR18–FR22 | Browser tests with real touch input (`spec:AST-013` FR10) | per-axis pans beside native scrolling, page zoom, cancelled touches, clicks after taps, keyboard activation, a modal scroll lock, a control that keeps its press through a drag; a still finger with sub-pixel jitter over a scroll view; a finger moved 9 px and 10 px straight, and (7, 7) and (8, 8) diagonally; a recognizer on an element whose author `touch-action` is narrower, including one without `pinch-zoom`; a screen-edge pan landing at 40 px and at 41 px from the edge, at 14 px and 15 px of travel, and a horizontal scroll that starts outside the band; a screen-edge pan on an element within the band, and on one that reaches beyond it; a sheet's pull from a list at its top, and from a list scrolled away from its top; a long press dragged past its tolerance after it began, which never scrolls the page | a ghost click, a scroll or zoom blocked other than by the author's `touch-action`, or a cancelled unowned touchmove outside FR19's five exceptions, a tap cancelled by sub-pixel movement or by under 10 px of travel, a scroll that does not take the touch at 10 px, or a derived `touch-action` wider than the author's, a screen-edge pan that claims outside its band or before 15 px on an element within the band, or has not claimed at 15 px, or an author scroll outside the band that is blocked, a band claim of `pan-x` on an element that reaches beyond the band, or a 15 px start there, or a scroll-edge pan that cancels a move a scroller could scroll, or begins before 10 pt, fails | +| FR18–FR22 | Browser tests with real touch input (`spec:AST-013` FR10) | per-axis pans beside native scrolling, page zoom, cancelled touches, clicks after taps, keyboard activation, a modal scroll lock, a control that keeps its press through a drag; a still finger with sub-pixel jitter over a scroll view; a finger moved 9 px and 10 px straight, and (7, 7) and (8, 8) diagonally; a recognizer on an element whose author `touch-action` is narrower, including one without `pinch-zoom`; a screen-edge pan landing at 40 px and at 41 px from the edge, at 14 px and 15 px of travel, and a horizontal scroll that starts outside the band; a screen-edge pan on an element within the band, and on one that reaches beyond it; a sheet's pull from a list at its top, and from a list scrolled away from its top; a long press dragged past its tolerance after it began, which never scrolls the page | a ghost click, a scroll or zoom blocked other than by the author's `touch-action`, or a cancelled, unowned touchmove outside FR19's six exceptions, a tap cancelled by sub-pixel movement or by under 10 px of travel, a scroll that does not take the touch at 10 px, or a derived `touch-action` wider than the author's, a screen-edge pan that claims outside its band or before 15 px on an element within the band, or has not claimed at 15 px, or an author scroll outside the band that is blocked, a band claim of `pan-x` on an element that reaches beyond the band, or a 15 px start there, or a scroll-edge pan that cancels a move a scroller could scroll, or begins before 10 pt, fails | | FR19 (DEC-30) | Gesture unit tests on synthetic streams; browser tests with real touch input in WebKit and Chromium | a tap that wobbles 2–4 px toward a scroll edge keeps every move, and a 5 px move is cancelled; a sideways move is never held; NavigationStack's content back swipe on a pushed screen; RefreshControl's pull at its top, whose touch path is not a scroll-edge pan (a guard) | a move under 5 px along the pan's axis cancelled, a move from 5 px left uncancelled while every scroller under the finger sits at its edge, a sideways move held, or a pan that begins before its hysteresis fails | | FR20 | Browser tests with real touch input in Chromium phone emulation (`spec:AST-013` FR10) | a horizontal drag under `pan-y`; a vertical drag under `pan-y` over a scroller with room; a vertical drag where no scroller has room | a horizontal drag under `pan-y` counted as the browser taking the touch, a vertical one over a scroller with room not counted, or a later uncancelable move counted, fails | | FR23 | Haptics tests on the recorded moments | tap, drag, lift | a haptic outside a native moment fails | diff --git a/docs/specs/AST-099-mobile-keyboard/spec.md b/docs/specs/AST-099-mobile-keyboard/spec.md index 26ed48b792af9..52f59da4dafb8 100644 --- a/docs/specs/AST-099-mobile-keyboard/spec.md +++ b/docs/specs/AST-099-mobile-keyboard/spec.md @@ -28,6 +28,7 @@ affects_consumer_docs: { "paths": [ "packages/core/src/BottomSheet/**", + "packages/core/src/Dialog/**", "packages/core/src/TextInput/**", "packages/core/src/TextArea/**", "packages/core/src/NumberInput/**", @@ -95,9 +96,22 @@ app to turn on. visual viewport's scale, in CSS pixels. It is 0 when no keyboard is shown, including while the page is pinch-zoomed. A page pan or a visual-viewport offset is a pan to put back (FR4), never a smaller keyboard. -- **FR3 — The keyboard height stays internal and keeps layout correct.** No - public CSS custom property, export, or prop exposes the keyboard height. Each - component applies it on its own element, such as a bottom offset, a padding, +- **FR3 — Apps read one keyboard value, and layout stays correct.** Core gives + apps the keyboard as one read-only value from its public keyboard entry, + `@astryxdesign/core/keyboard` (DEC-7): the keyboard height (FR2), whether a + keyboard is up, and whether it has settled at that height, with a + notification when it settles. A Core host may publish a read-only layout + value that includes the keyboard's lift; that host's component record names + and defines it (DEC-7). Where the host shrinks the layout viewport for + the keyboard, as a page that sets `interactive-widget=resizes-content` or an + app's web view that resizes for it, the height reads 0 (FR2, FR8), and the + value still says whether a keyboard is up under a coarse primary pointer + (FR6, DEC-9). Lab components read the same + value through Core's internal keyboard entry (DEC-9). Core's surfaces read it at the same + moment (FR1). No CSS custom property on the document + root or a shared ancestor carries it, and no prop sets it. Each component, + and each app element that reads it, applies it on its own element, such as a + bottom offset, a padding, or a maximum height, so layout is correct with no animation running: the chat composer, a search field placed at the bottom, and tab bar search position from it, and a fully expanded sheet extends its own scroll range by it. FR9's @@ -109,9 +123,10 @@ app to turn on. the same motion to the resting value with no per-frame layout work, and each commits the resting value once to layout, as an offset, a padding, or a spacer, so nothing is hidden or unscrollable. How the motion is shared is - `architecture:react-component-runtime` INV11; no public API or CSS custom - property exposes it. In Safari on iOS, which reports the keyboard only once - it is down, a fully expanded sheet + `architecture:react-component-runtime` INV11; no public value or CSS custom + property exposes the motion. An app element that reads the value commits the + resting value once. In Safari on iOS, which reports the keyboard's hide only + once it is down, a fully expanded sheet whose field loses focus to a control that brings up neither a keyboard nor a picker in the keyboard's place keeps its keyboard layout and moves its content to its resting scroll on the motion the keyboard's own hide plays @@ -126,7 +141,13 @@ app to turn on. control into view with its own scroller. When the keyboard's Done button ends entry, focus moves to the surface so the next tap is handled the same way. A document scroll that still happens while the page is scroll-locked, - such as on returning to the app, is put back in the same frame. + such as on returning to the app, is put back in the same frame. While the + keyboard shows and a container rides it under FR9, a Core host or an app's + docked bar, a one-finger drag that starts on that container does not pan the + page: Core + holds the page for it (`spec:AST-094` FR19), unless a scroller inside the + container takes the drag or the page is pinch-zoomed (DEC-10). A browser's own + pan to a field in a riding container is put back in the same frame. - **FR5 — Moving a surface dismisses the keyboard.** When a surface that holds the focused control starts to move, such as a sheet dragged between heights, a drag to dismiss, or a close, the control is blurred so the keyboard @@ -141,11 +162,27 @@ app to turn on. comes from FR2 there too and FR8 governs how surfaces ride the keyboard, on any device that shows an on-screen keyboard; a browser that offers the report but shows no on-screen keyboard reads 0. A page that is not a secure context gets - no such report, so FR8 does not apply there. -- **FR7 — Top-level documents only.** Inside an iframe the frame's visual - viewport does not change when the keyboard opens, so the keyboard height is - 0 there and nothing changes. Behavior and evidence for this record come - from a top-level document. + no such report, so FR8 does not apply there. A host can instead shrink the + layout viewport for the keyboard. There Core reads a keyboard as up while a + text-entry control has focus and the layout viewport is at least 100 px + shorter than before the first of consecutive text-entry focuses, at the same + width, and FR2's height is 0. The signal applies only under a coarse primary + pointer, where an on-screen keyboard can show. After a rotation while a + text-entry control keeps focus, the state holds until the layout viewport + changes by at least 100 px at the new width: shorter reads a keyboard as up, + and taller as not up. +- **FR7 — A frame reads the keyboard from the page that embeds it.** Inside an + iframe the frame's visual viewport does not change when the keyboard opens. + When the page that embeds the frame runs Core, it sends FR3's value only to + the frame that holds focus. The value carries the height of the keyboard that + covers the frame's box. When focus leaves that frame, the page sends it one + last value with no keyboard over it, so its lift returns to 0. The page posts + to the frame's own origin, taken from its `src`, never to `*`. The frame + accepts the value only from its parent window, and Core in the frame acts on + it as in a top-level document (DEC-8). A sandboxed frame with an opaque origin + receives no value and reads 0. Focus routes, the focus claim + and FR9's reveal act inside the frame; the embedding page keeps its own. A + frame that receives no value reads 0, and nothing changes there. - **FR8 — Browsers that report the keyboard ride it smoothly.** In a browser that reports the on-screen keyboard's geometry itself, such as Chrome on Android, the keyboard height comes from FR2's visual-viewport @@ -249,7 +286,8 @@ app to turn on. `translate: -50% 0`, is not moved. The bar's resting state is that move, not a change to its layout, and the move is gone once the keyboard hides after the field loses focus, or once the field unmounts. Core changes nothing else - on the app's elements. This is the one exception to FR3 (DEC-5). + on the app's elements. This is the one exception to FR3's rule that a + component moves only its own elements (DEC-5). - **No API.** No prop, option, context, or other public API turns this on, turns it off, or tunes it, and for a field in the places above the app does nothing to get it. Every route by which a field gains focus (FR4) gets the @@ -272,12 +310,22 @@ app to turn on. trigger, FileInput, Slider, and a Selector or ComplexSelector trigger. Lab fields follow INV11's rule for components outside Core. +- **FR10 — A field focused after a tap still brings up the keyboard.** When a + tap opens a Core surface whose initial focus is a text-entry field that mounts + after the tap, such as a Dialog or a BottomSheet that focuses its field as it + opens, that focus brings up the keyboard in every browser. Safari on iOS + raises the keyboard only for a focus made inside the tap, so Core carries the + tap's focus to the field (DEC-11). A surface opened without a tap, or whose + initial focus is not a text-entry field, brings up no keyboard. The page does + not pan for that focus (FR4). + ### Platform support - Supported feature/engine floor: the package's supported browsers (`spec:AST-013` FR3). FR2–FR5 apply to Safari on iOS, in the browser and as a home-screen app, and to Firefox for Android; FR8's ride applies wherever the - browser reports the keyboard itself, such as Chrome on Android. + browser reports the keyboard itself, such as Chrome on Android. FR7 applies to a frame whose embedding page + runs Core, and FR10 to every browser. - Unsupported behavior: with no on-screen keyboard, or no visual-viewport support, the keyboard height is 0 and nothing changes. During server render it renders nothing and reads no viewport. @@ -341,7 +389,20 @@ app to turn on. `BottomSheet.doc.mjs` documents and moves with the keyboard, so no consumer loses behavior and no breaking change applies; `BottomSheet.doc.mjs` states each platform's behavior. Firefox for Android gets FR2–FR5. -- No public API exposes the keyboard height, and FR3 keeps it that way. +- FR3's public entry, `@astryxdesign/core/keyboard`, gives an app the keyboard + value. An app that measured the keyboard itself by + `architecture:react-component-runtime` INV11's rule for code outside Core + reads that value instead, so it agrees with Core's surfaces. Lab reads it + through Core's internal keyboard entry. +- FR3 gap: Core has no public or internal keyboard entry. FR4 gap: a + one-finger drag that starts on a riding container pans the page in Safari on + iOS. FR6 gap: nothing reads a keyboard as up where the host shrinks the + layout viewport. FR7 gap: a frame reads 0. FR10 gap: a field focused after a + tap's open brings up no keyboard in Safari on iOS. +- A searchable Selector or MultiSelector touch sheet focuses its search field + as it opens (`component:Selector` AR2, and `component:MultiSelector` FR8 for + a caller-rendered trigger; MultiSelector's own trigger opens its sheet the + same way). Under FR10, the keyboard then comes up over its options. - The keyboard module reads the input stream's touch counts through one reader, `getTouches`, which `packages/core/src/utils/inputStream.ts` exports. A finger in a native pan has no press in `getDownPresses`, and reading a count adds no @@ -451,13 +512,13 @@ that sets its own `translate`, to the app. | Contract | Verification | Representative states | Mutation or failure expectation | | -------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| FR1 | Source boundary check over Core and Lab plus a shared test that drives one keyboard change | each listed consumer; a new keyboard-aware component | Two components reading different heights for one keyboard, or a component measuring by a rule other than FR2 | +| FR1 | Source boundary check over Core and Lab plus a shared test that drives one keyboard change | each listed consumer; a new keyboard-aware component | Two components reading different heights for one keyboard, or a component measuring by a rule other than FR2, or a component outside Core measuring the keyboard itself | | FR2 | Module tests driving visual-viewport resize and scroll events | keyboard shown; hidden; page panned with the keyboard shown; offset without a keyboard; page pinch-zoomed with and without the keyboard | A pan that lowers the reported height, or a height when no keyboard is shown | -| FR3 | Consumer tests of computed layout, plus a public-surface check | keyboard shown and hidden; composer, bottom search field, tab bar search, Tall sheet; no animation running; a ride animation running with the composer, a scroll view, and a header together; a Tall sheet's field blurred in Safari on iOS | A consumer whose layout ignores the height, layout that is only correct after an animation, riding surfaces out of sync on one keyboard change, per-frame layout work during a ride, content hidden or unscrollable at the resting value, or a public CSS custom property, export, or prop for the height; a Tall sheet's content jumping at a late keyboard report | +| FR3 | Consumer tests of computed layout, plus a public-surface check | keyboard shown and hidden; composer, bottom search field, tab bar search, Tall sheet; no animation running; a ride animation running with the composer, a scroll view, and a header together; a Tall sheet's field blurred in Safari on iOS | A consumer whose layout ignores the height, layout that is only correct after an animation, riding surfaces out of sync on one keyboard change, per-frame layout work during a ride, content hidden or unscrollable at the resting value, or a public CSS custom property or prop for the height; a Tall sheet's content jumping at a late keyboard report | | FR4 | Focus-route tests with document scroll spies | tap, previous and next buttons, Tab, programmatic focus, Done then tap, app resume while scroll-locked | A route where the browser scrolls the document to reveal the focused control, or a slipped scroll left in place; FR9's own reveal scroll by the field's nearest scroller is not a failure | | FR5 | Surface move tests | sheet drag between heights, drag to dismiss, close, with a focused field | The field stays focused after a move starts, or content jumps on the first frame | | FR6 | Capability tests with the user agent varied | visual viewport shrinking with a fixed layout viewport; Chrome on Android reporting keyboard geometry; a desktop browser with the API and no on-screen keyboard; a page that is not a secure context; neither | Behavior that changes with the user agent alone, or a height taken from the browser's keyboard geometry report instead of FR2's measurement | -| FR7 | Tests in an iframe and in a top-level document | the same keyboard event sequence in both | A non-zero value or a claimed focus inside an iframe | +| FR7 | Tests in an iframe and in a top-level document | the same keyboard event sequence in both | A non-zero value in a frame whose embedding page sends none | | FR8 | Chrome on Android in the emulator with Gboard, top-level document, plus a consumer documentation check | keyboard show and hide with the composer and a Tall sheet; a Lab bottom search field; reduced motion on; focus inside a keyboard-aware field, which rides by the visual-viewport height; an app with `interactive-widget=resizes-content`, focus inside and outside keyboard-aware fields, where a field's keyboard height is 0; Back: the ride starts at Chrome's hide report | A Core surface jumping after the keyboard settles, lagging the keyboard by more than a frame, left under the keyboard, moved by JavaScript per frame, or committing layout more than once; a Lab surface riding instead of committing at rest; anything travelling with the keyboard under reduced motion instead of DR2's cross-fade; the app's viewport setting overridden; a keyboard-aware field not riding by the visual-viewport height, or adding an offset under `interactive-widget=resizes-content`; or the setting missing from the docs | | FR8 | Firefox for Android in the emulator, top-level document | focus routes, keyboard shown and hidden, page panned and pinch-zoomed, a sheet moved | The page lurches, the field ends under the keyboard, or the height is wrong after a pan or zoom | | FR2–FR5 | Safari on iOS in the iOS Simulator or on a device, top-level document | focus routes, keyboard shown and hidden, page panned and pinch-zoomed, a sheet moved, ChatLayout's composer, in Safari and as a home-screen app | The page lurches, the field ends under the keyboard, or the height is wrong after a pan or zoom | @@ -474,6 +535,10 @@ that sets its own `translate`, to the app. | FR9 | TBD (Gap 11): a ride test per covered field, plus physical-device evidence under DEC-3 | each covered field in a fixed bottom bar, a sheet, an app-owned bar whose layout box sits at the viewport's bottom edge; an app bar the app lifts to the keyboard's top on the same visual-viewport resize, with its listener running before and after Core's; an app bar the app lifts part of the way with its own transform; an app bar the app lifts behind a CSS transition or animation still running when Core measures; an app bar the app lifts from script with its own `translate`; a keyboard that changes height while focus stays in a docked bar; an app bar centred with its own `translate`; an app bar floating above the bottom edge; an app-owned fixed container that fills the viewport, with and without a scroller holding the field; a full-height side drawer with a scroller holding the field; a tall pane below a fixed header with no scroller and a field near its top; the same pane with a field near its bottom; keyboard show and hide; the field blurs; the field unmounts; reduced motion on | The docked container stays put, lags or jumps after the keyboard settles, a Core host or content field less than 10 CSS px above the keyboard, an app bar left under the keyboard or above its top edge once the keyboard settles, a move left on an app element after the keyboard hides once focus has left the field, or after the field unmounts, any other change on an app element, a bar the app lifts moved a second time, a bar the app is moving with CSS motion moved by Core, a bar with its own `translate` moved, a docked bar not updated when the keyboard changes height, a floating bar moved, the app's transform replaced, a bar with its own `translate` moved or its `translate` changed, the page is panned or translated, a fixed container that fills the viewport, or whose layout box is not at the bottom edge, moves, or a Core host that already rides is moved twice; a too-tall docked container moved when a scroller holds the field or when the field already clears the keyboard, moved more than the field needs to clear it, or a field near its bottom left under the keyboard; a field that a scroller holds inside a container FR9 leaves to the app, left under the keyboard. A container FR9 leaves to the app (floating above the bottom edge, with its own `translate`, or full-viewport) left under the keyboard, or a page pan from the browser's own reveal for a field with no scroller between it and that container, is not a failure | | FR9 | Safari on iOS in the Simulator, top-level document | A TextInput in the middle of a page that scrolls the document: tap it and read every drawn frame until the keyboard settles | The field reaches its place in one frame with no position between, or settles more than 0.15 s after the keyboard settles | | FR9 | Safari on iOS in the Simulator, top-level document | A TextInput in the middle of a page that scrolls the document: focus it, then close the keyboard with Done and read every drawn frame until the page rests; again after a scroll of the page while the keyboard shows; again with the field tapped 80 ms and 150 ms after Done | The page ends other than where it was before the reveal (to 0.5 CSS px); a scroll the person made while the keyboard showed is undone; the page starts back only after the keyboard has gone, or moves at the report that it has gone; or a field tapped again during the slide ends under the keyboard | +| FR3 | A public-surface check of both entries, consumer tests, and a browser test beside a Core surface | keyboard shown, settled and hidden; a pan and a pinch zoom with the keyboard shown; a resume; an app element beside ChatLayout's dock; a host that shrinks the layout viewport for the keyboard, with a move from field to field, a toolbar change, a rotation, and Back after a rotation; a fine pointer with a shorter window | The app element and a Core surface disagree in a frame, the settle notification fires before the keyboard settles, or the value reaches a CSS custom property on a shared ancestor, or, in a host that shrinks the layout viewport under a coarse primary pointer, the value says no keyboard is up while one shows, or one is up when none shows | +| FR4 | Safari on iOS in the Simulator and Chrome on Android in the emulator: a drag starting on a riding container | a docked bar Core rides; a scroller inside the container; a pinch-zoomed page | The page pans under the drag, or a scroller inside the container stops scrolling | +| FR7 | Browser tests of a same-origin and a cross-origin frame, with and without Core in the embedding page | a field in the frame near its bottom; a frame partly under the keyboard; a frame without focus while the host page's field is focused; focus leaving a frame mid-keyboard; a frame sandboxed without `allow-same-origin` | A frame reads a value its embedding page did not send, or a field in the frame ends under the keyboard, or a frame without focus receives anything, or a frame's lift stays above 0 once focus leaves it | +| FR10 | Safari on iOS in the Simulator and on an iPhone: a tap that opens a Dialog or a sheet that focuses a field | a field that mounts at once; a field that mounts after the open's motion; a surface opened from a key | The keyboard stays down, or comes up for a surface opened without a tap | ## Decision log @@ -613,6 +678,97 @@ that report. Rejected: a fast slide, which Chrome's pan still overtakes when the page stalls; the VirtualKeyboard overlay setting, which changes DEC-4's measurement source and the page's layout. +### DEC-7 — Apps read one keyboard value + +**Reference:** `spec:AST-099/DEC-7` +**Decider:** pending + +Some parts of an app cannot sit in a Core field or host, such as a floating +button, a floating player, a full-viewport panel whose last line ends at the +keyboard, or a bar that hides while a person types. To stay clear of the +keyboard, each needs the keyboard's height or whether it is up. Without a +public value, each app keeps its own measurement beside Core's, and the two can +disagree after a pan, a pinch zoom or a resume, which DEC-1 exists to prevent. +One read-only value keeps every surface on one height (FR1) and keeps the +measurement in Core. The notification at rest serves work that waits for the +keyboard to settle. No app sets the value, and no CSS custom property carries +it, so DEC-1's reason against a shared variable stands. It is the deliberate +public-API decision that DEC-1 leaves to a later need. + +A Core host may publish a read-only layout value that includes the keyboard's +lift, such as the room a chat layout keeps after its messages; that host's +component record names and defines it. A list that measures from its own +content's end then stays clear of the keyboard with no keyboard reading of its +own. + +Rejected: a CSS custom property on the root (DEC-1); a public copy of the keyboard module's hook and its focus claim; a public motion clock, which serves only browsers that report the keyboard (FR8). + +### DEC-8 — A frame reads the keyboard from the page that embeds it + +**Reference:** `spec:AST-099/DEC-8` +**Decider:** pending + +An editor or a conversation embedded in an iframe sees no keyboard, so a field +in it can end under the keyboard. The page that embeds it measures the keyboard, +so it sends DEC-7's value only to the frame that holds focus. The value carries +the height of the keyboard that covers the frame's box. A frame without focus +learns nothing of the keyboard. When focus leaves the frame, one last value with +no keyboard over it keeps no lift behind. The page posts to the frame's own +origin, taken from its `src`, never to `*`. The frame accepts the value only +from its parent window. + +Rejected: reading the embedding page's viewport, which a cross-origin frame cannot do; sending every frame the value, which tells unknown frames when someone types. + +### DEC-9 — Lab reads the keyboard's state through Core's internal entry + +**Reference:** `spec:AST-099/DEC-9` +**Decider:** pending + +A Lab component that hides while a keyboard is up, such as a tab bar, needs the +keyboard's state. Lab cannot import Core's keyboard hook, and a listener of +Lab's own would measure apart from Core (FR1). Core's internal keyboard entry +gives Lab DEC-7's value, read-only. Lab rides nothing; a Lab surface commits +the resting value once (FR8). + +A host can shrink the layout viewport for the keyboard, as a page that sets +`interactive-widget=resizes-content` or an app's web view that resizes for it. +There FR2's height reads 0, but a tab bar still needs to know that a keyboard +is up. So under a coarse primary pointer the value says a keyboard is up there +too, while the height stays 0. +100 px sits above the viewport change a browser's own toolbar makes and below +the smallest on-screen keyboard. + +Rejected: a keyboard listener of Lab's own. + +### DEC-10 — A drag on a riding container does not pan the page + +**Reference:** `spec:AST-099/DEC-10` +**Decider:** pending + +FR4 keeps focus routes from panning the page. Safari lets a person's own drag +pan the visual viewport under a container that rides the keyboard, and the +container then leaves the keyboard's top. Core holds the page for a drag that +starts on such a container, as a scroll lock under a modal presentation does +(`spec:AST-094` FR19). A scroller inside the container still takes its own +drags. The browser's own pan to a field in a riding container is put back, as +for Core's composer. + +Rejected: moving the container with the pan, which leaves content under the keyboard. + +### DEC-11 — A field focused after a tap brings up the keyboard + +**Reference:** `spec:AST-099/DEC-11` +**Decider:** pending + +Safari on iOS raises the keyboard only for a focus made inside a tap. A Core +surface that focuses its field as it opens, after the tap, then shows a focused +field with no keyboard. Core carries the tap's focus to the field, so the +keyboard comes up as in other browsers. A surface opened without a tap brings up +no keyboard, and a surface that defers its field's focus, such as a sheet that +keeps its options in view, brings up none until the person taps the field. + +Rejected: requiring each app to focus the field inside its own tap handler. + ## Open questions None.