Make keyboard docking responsive with large lists and reusable across apps

Aperta
#844 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript

Direzione di ricerca

Start by reconciling the local hook repair against current main and reviewing CONTRIBUTING.md for the alternatives audit. The issue names useKeyboardInset, useKeyboardSurface, ChatComposer.stories.tsx, the Contacts src/KeyboardLayout.tsx, and acceptance checks, but does not point to exact test files or entry points. Done requires reviewed public primitives and composition, updated examples and documentation, a published release, Contacts migration, and the listed browser and native regressions.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Outcome

Make keyboard docking a supported MIEUI composition that stays responsive with large content, then migrate Ozwell Contacts to the released implementation. Another application should be able to compose a search/composer dock, scrolling content, and overlays without rebuilding the keyboard lifecycle, spacing, background, and performance protections.

This is follow-up work to #514, which added the native feed. Coordinate the runnable Capacitor/browser demonstration with #841 rather than create another competing reference app. Component-specific editor focus behavior in #672 remains separate.

Problem and present state

Ozwell Contacts initially had correct settled search-field geometry but visibly froze or disappeared while its keyboard opened. Company had 12 records and appeared fast; All had 2,230 records, including 2,200 synthetic personal contacts in the reproduction, and took roughly one second to settle.

A validated local repair now works on the installed phone, and the user reports it working well. However, other consumers do not receive the complete solution through normal component composition yet:

Area Present implementation
List/input/button Standard MIEUI components; ListView and row rendering are unchanged.
Keyboard primitives Local changes in mieweb/ui: enhanced useKeyboardInset, new useKeyboardSurface, exports, styles, tests and reference-story changes.
Contacts integration A Contacts-specific src/KeyboardLayout.tsx still coordinates selectors, local dock classes, content reservation, native source selection, navigation/detail policy and a small-pan threshold.
Dependency delivery Contacts currently applies a ten-file patch-package backport to published @mieweb/[email protected]. This work has not published a library release.
Canonical example gap ChatComposer.stories.tsx → MobileKeyboardShellDemo still publishes metrics globally and generates 30 message elements inside the keyboard state owner. It does not demonstrate the final composition that avoids large-list work.

At ticket creation, upstream main still has the earlier inset hook and no useKeyboardSurface. Reconcile against current main before implementation; the existing repair is local/uncommitted, not an immutable upstream commit.

Findings that must survive the upstream work

  1. Keep expensive children stable. Owning keyboard state in the component that creates every row caused unnecessary React work before animation. A small layout owner can move surrounding controls without recreating those children.
  2. Limit style invalidation. Inherited metrics on html, keyboard classes on an ancestor of the whole list, and edits to stylesheet-rule declarations caused work across unrelated content. The validated path publishes metrics inline only on the small consuming surfaces and uses local dock classes/non-inherited content spacing.
  3. Prepare the document layer early. Adding a backdrop directly under body during opening independently reproduced the remaining stall. Create one owned, decorative display: contents layer when the hook mounts, then add/remove the temporary backdrop inside it. Keep direct body children stable throughout opening and closing.
  4. Commit geometry together. Native will-show/hide events and scheduled Visual Viewport measurements must publish CSS and React layout before later geometry readers run. A delayed browser padding update broke retained-pan Back alignment by 68px; the corrected path commits before an independent same-frame reader. Height/pan-only changes must notify consumers even when public keyboard fields are unchanged.
  5. Separate total keyboard height from remaining inset. A zero remaining inset can coexist with an open keyboard after viewport panning. Use stable layout-viewport measurements when innerHeight is transient; preserve pinch-zoom handling and browser fallback behavior.
  6. Measure the full transition and actual accessibility. Final bounds and a small demo concealed the pause. A trial content-visibility workaround exposed only 11/2,200 fixture buttons through native accessibility and was removed entirely. DOM role locators or a special browser screen-reader mode alone did not establish native accessibility.

These findings concern surrounding keyboard/layout work, not a requirement to virtualize or fork ListView. Do not reintroduce the removed list-rendering workaround as part of this ticket.

Implementation checklist

1. Upstream the proven primitives in a focused change
  • Review/port the local hook changes, public exports, CSS helper and unit/browser regressions against current main; preserve existing default HTML publication for compatibility.
  • Support total keyboardHeight separately from keyboardInset, opt-in native usable-height metrics (nativeViewport), and scoped inline publication (cssSelector or a reviewed equivalent).
  • Initialize newly mounted portal/overlay targets with current metrics. Restore original inline values and priorities on removal, disable, option changes and unmount. Avoid stylesheet-wide updates and mutation-observer loops.
  • Keep native viewport geometry cached under the documented non-resizing host contract; refresh on actual window resize. Preserve atomic native event commits and scheduled browser measurement commits, including geometry-only notifications.
  • Include the stable body layer, opaque coverage and covered-content tap shielding. Read geometry before writes, skip unchanged writes, follow dock transitions with bounded frame tracking, retain coverage during closing, and handle fast reopening and reduced-motion native height changes.
  • Clean up every listener, observer, frame, timer, scoped value, temporary backdrop and owned layer. Verify Strict Mode mounting, disable/re-enable, no-VisualViewport fallback, and original scroll-height preservation.
  • Verify supported ESM, CJS, declaration and public hook entry points. Preserve the consumer's single React runtime and review the synchronous-commit dependency/behavior.
2. Provide the shared layout/dock composition
  • Follow the alternatives audit in CONTRIBUTING.md: inspect existing layout, overlay and composer primitives before choosing whether to compose, extend or add a component. Document the user need, alternatives, relationships and limits.
  • Provide a small public composition using generic refs/slots or explicit targets for content, dock and overlays. Final API naming is a maintainer design decision; the current Contacts class selectors are not the API.
  • Have the shared composition own keyboard state isolation, scoped metric application, reusable content reservation, safe-area handling and background lifecycle. Make the efficient composition straightforward by default for new consumers.
  • Define one measurement owner per document/provider and clear ownership for multiple docks and nested overlays. Unmounting one consumer must not clear another active consumer's metrics. Explicitly document unsupported combinations instead of adding an unnecessarily broad provider design.
  • Retain application policy in Contacts: which tabs/actions appear, list versus detail navigation, contact data and authorization. A thin adapter may remain; generic keyboard machinery should no longer be reimplemented there.
  • Demonstrate the same public abstraction in two independent consumers: a directory/search example and a ChatComposer/conversation example. Neither should need a copied version of Contacts' orchestration.
3. Correct examples and document the native host contract
  • Replace the current 30-message keyboard story with scoped publication and stable expensive children. Add a realistic large-content variant and link the public API, rationale, alternatives and limitations from affected component pages.
  • Use the shared composition in the bare Capacitor/browser example coordinated with #841; include nested dialogs/sheets so portal initialization is demonstrated outside Storybook as well.
  • Document early native keyboardWillShow/keyboardWillHide events, WebView resizing/panning disabled, source selection and accessible system Done retained. The validated Contacts host uses Capacitor Keyboard with resize: 'none' and explicitly preserves the accessory bar.
  • Keep Capacitor/Cordova setup or an optional adapter outside generic UI core. Do not silently add a native runtime dependency for browser-only consumers.
  • State browser fallback timing limitations, safe-area and keyboard ownership, transition/reduced-motion policy, and how applications handle small retained viewport pans. Do not hard-code Contacts' 100px policy for all devices.
  • Add consumer migration guidance, component/catalog metadata and maintainer notes under the repository's documented conventions.
4. Release and migrate Contacts
  • Land focused upstream changes with maintainer review, durable source/evidence links and complete quality checks; coordinate rather than overwrite unrelated work in either dirty checkout.
  • Publish a normal MIEUI release containing the public composition and hooks. Verify a clean installation/build against the published package rather than only a working-tree alias.
  • In a linked Contacts integration PR, adopt that release and replace reusable KeyboardLayout machinery with the public composition, retaining only application policy.
  • Remove patches/@mieweb+ui+0.11.0.patch; remove patch-package/postinstall only if no other patches require them. Update the lockfile, integration docs and reproducible build instructions.
  • Re-run browser and native integration acceptance against the released dependency and capture the exact installed build. Close this issue only when normal consumers can obtain the fix and Contacts no longer requires the backport.

Acceptance and regression requirements

  • A production-mode fixture compares 12 rows with at least 2,200 rows using the same controls; adding the large list must not reproduce a list-length-dependent frozen keyboard transition. Preserve all records and their accessible names.
  • Structural checks prove: expensive children do not rerender on keyboard-only updates; no metric inheritance into unrelated rows; no hot-path stylesheet-rule edits; and zero keyboard-surface-driven direct body-child additions/removals during toggles after initial mount. Isolate this lifecycle check so legitimate modal/portal mounts are not incorrectly forbidden.
  • Capture opening, typing, keyboard-open scrolling, dismissal, reopening, fast reopen, height changes and reduced motion. Verify continuous motion, pinned header, opaque background/tap shielding, correct final bounds, last-row clearance and ordinary scrolling afterward.
  • Exercise nested sheet→dialog and Break Glass reason→Cancel→Back flows. One accessible Cancel activation must dismiss without granting access or leaving scrolling locked. Do not introduce competing body.style.overflow save/restore ownership.
  • Cover 320px/390px phones, compact heights, landscape/iPad, safe areas, English/Arabic RTL, mixed-script names, expanded/wrapped text, viewport resize and late retained-pan changes. Common controls must preserve complete 44×44 minimum bounds and usable lower-half placement for the Contacts integration.
  • Verify light/dark themes and brand switching, including the backdrop matching the dock's current opaque background during an open keyboard and after reopening.
  • Inspect the actual browser platform AX tree in ordinary mode and the actual native target app tree. Discover all 2,200 synthetic row controls, discover the last mixed-script row before scrolling/focusing it, then complete search→result activation→Back. DOM-only locators do not replace these checks.
  • Preserve the existing stressed browser budget as a starting regression gate: with 4× Chromium CPU throttling, first movement under 200ms for both cases, All no more than 150ms behind Company, multiple intermediate motion frames and no header movement. Run performance measurements serially with a stable production fixture; record raw timings and conditions. These are test-environment budgets, not universal device promises.
  • Include a cold All-first opening as well as warm Company→All transitions so a warmed keyboard, fonts or prior small-list render cannot conceal startup/scale work.
  • Repeat native simulator measurements with a matched dataset, independent video and native AX-driven UI. Record event-to-next-frame and full opening motion separately, with build/OS/device/count metadata. Do not claim hardware FPS or physical-device performance from resampled simulator clips.
  • Add project-owned scripts/CI for the regression route; do not depend on /tmp harnesses or a developer's already-running server. Run the repository quality gates, RTL/catalog checks, JS/types build, Storybook and relevant visual/native tests. Test the example without Storybook manager/iframe dependency.
  • Follow the shared iOS testing/device-session guard for any physical verification: simulator first, explicit authorization or concrete device-only gap, bounded ownership, cleanup and verified release. A remote-control accessibility fallback remains a failed accessibility test with a durable repair/retest follow-up.

Existing evidence and limits

Results below are from the validated local repair, not a published shared component:

Check Before Repaired
Native simulator All opening, 2,230 total contacts ~1,083ms ~283ms; Company ~233ms
Native keyboard event → next frame, diagnostic copy Earlier All stalls were hundreds of ms All 15ms / Company 4ms
Stressed Chromium All first movement, 2,200 injected personal contacts 1,008.5ms 40.6ms
Stressed Chromium All style recalculation ~694ms ~7.2ms
Browser/native accessibility after final repair Every synthetic row required All 2,200 exposed; original ListView retained
  • Heavy native run: iPhone 17 Pro simulator, iOS 26.0, 2,230 All / 12 Company; app 0.5.2 (18), bundled build 2026-11-24T10:09:28.638Z, eight native AX workflows passed.
  • Final build: 2026-11-24T10:15:19.468Z. It adds the browser retained-pan coherency repair; separate ordinary native smoke passed four checks after fixture cleanup. Keep the two build stamps distinct.
  • Existing validation: 113 shared unit tests, seven shared browser checks, 360 Contacts unit tests, 106 focused mobile/overlay/keyboard/scroll checks, and two large-directory tests. One unrelated obsolete personal-audit expectation was reproduced as failing on the pre-change build and excluded; do not silently count it as passing.
  • The signed final build was installed and launched on the phone and the user confirmed improvement. The numbers above are simulator/browser evidence, not physical-device timing or universal scalability guarantees. The browser scale fixture had no photos. Add representative photo coverage before making broader rendering claims.
  • All 2,200 owned simulator fixtures and test runners were cleaned up. The earlier physical AX bridge follow-up remains distinct from functional phone feedback.

Starting source and evidence inventory

The following files exist in the author's local working trees. Some are modified/untracked and are not yet available as committed GitHub files. Before delegation/review, put the relevant source in a fetchable upstream branch/PR and publish sanitized clips/reports; replace local-only references with immutable review links. A dirty build's embedded base commit is not the revision of this repair.

mieweb/ui

  • src/hooks/useKeyboardInset.ts, src/hooks/useKeyboardInset.test.ts
  • src/hooks/useKeyboardSurface.ts, src/hooks/useKeyboardSurface.test.ts
  • src/hooks/index.ts, src/styles/base.css
  • src/components/ChatComposer/ChatComposer.stories.tsx
  • tests/visual/keyboard-inset.spec.ts, tests/visual/keyboard-surface.spec.ts

horner/ozwell-contacts

  • src/KeyboardLayout.tsx, src/Mobile.scss, src/platform.ts, src/main.tsx, capacitor.config.ts
  • tests/keyboard-performance.spec.ts, tests/search-keyboard.spec.ts, tests/access-policy.spec.ts, tests/scroll-lock.spec.ts
  • patches/README.md, patches/@mieweb+ui+0.11.0.patch
  • docs/keyboard-performance-native-verification.json, docs/keyboard-performance-browser-verification.json
  • docs/screenshots/all-keyboard-before.mp4, docs/screenshots/all-keyboard-after.mp4, docs/screenshots/company-keyboard-after.mp4
  • docs/accessibility-follow-ups.md → AX-012 (removed experimental deferral; final native/browser retest passed), and the separate open AX-011 physical bridge follow-up

Follow mieweb/ui/CONTRIBUTING.md for the alternatives audit, reusable component documentation, catalog relationships, quality gates and linked consumer migration. The implementation should prevent other apps from rediscovering these rules, while preserving clear native-host and application-policy responsibilities.

Lingua principale
TypeScript
Stelle
2
Fork
7
Merge medio
1g 12h
PR unite (30g)
62

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mieweb/ui

Tutte le issue di mieweb/ui

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.