Skip to content

Run the example on @rootnative/web, and fix hitSlop, scrims and the search landmark on the web - #5

Merged
raajnadar merged 17 commits into
mainfrom
chore/example-on-rootnative-web
Nov 27, 2026
Merged

raajnadar merged 17 commits into
mainfrom
chore/example-on-rootnative-web

Conversation

@raajnadar

@raajnadar raajnadar commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

This PR moves the example app to @rootnative/web on the web, and adds browser tests that check the components on both web runtimes. It also fixes three faults of the components on the web.

The RTL fix of the first version of this PR (7e77103) is on main now.

1. The example on @rootnative/web

On the web, the example runs on @rootnative/web-expo ~0.0.9 in place of react-native-web. withRootNative in example/metro.config.js sends each react-native and react-native-web import to the package. With EXAMPLE_WEB_RUNTIME=react-native-web, Metro skips the wrap, and Expo's default runtime serves the web.

  • react-native-web 0.21.4 stays in the root tree for the web Jest projects of the packages.
  • The live demo on the docs homepage builds from the example. So the merge moves the demo to @rootnative/web.
  • The RTL screen and the RTL button of the example render their direction text after hydration (b369c8f). Before, /rtl in RTL failed hydration (React error #418) on both runtimes.

Commits: 53bcf29, 70564a0, 9a23c84, b6a10b2, bc20482, b03f7b1.

2. Component fixes

hitSlop on the web (687b113)

Button, Switch, ButtonGroup, Chip, Avatar, ListItem and Card turned hitSlop off on the web. They now pass it on each platform, so a web runtime that has the prop gets the 48dp touch target. react-native-web drops the prop, so nothing changes there.

  • Test: web/hit-slop.web.test.tsx (7 cases). On react-native-web, each component renders with no hitslop attribute and no warning.
  • docs/docs/accessibility.md now says that react-native-web doesn't correct touch targets.

A click on the scrim closes the overlay (8376794)

On react-native-web, a click on the scrim didn't close a Dialog or a BottomSheet after its entrance ended. SideSheet and NavigationDrawer had the same fault. Escape worked.

The cause: the animated layer has pointerEvents: 'box-none' in its style. Reanimated writes that style inline, CSS has no box-none value, and the browser drops it. The full-size layer then takes each click over the scrim.

  • New animatedBoxNone in internal/pointerEvents.ts: none on the web, box-none on native. Each surface gets pointerEvents.auto.
  • Dialog, BottomSheet, SideSheet, NavigationDrawer and SearchView use it.
  • Test: e2e/sheets.spec.ts. The jsdom tests can't see this fault. Only the browser tests do.

SearchBar and the SearchView header are a search landmark (05455df)

React Native's accessibilityRole="search" names a search field. react-native-web renders it on a View as the search landmark, but @rootnative/web renders it as searchbox, the role of the input inside.

  • New internal/searchLandmark.ts: role="search" on the web, accessibilityRole="search" on native. So both web runtimes give the landmark.
  • The registry entries of both components list the new file.

3. Docs

The Installation page and the introduction name both web runtimes, with @rootnative/web as the recommended one (af592cc). llms.txt and llms-full.txt say the same (87f39a0). The Installation page also says that hitSlop has no effect only on react-native-web.

4. Browser tests

example/e2e/ has a Playwright suite: 297 tests in 13 spec files.

  • Each of the 46 routes, in LTR and RTL, at full width and at 390 px: the heading renders, the page doesn't scroll sideways, each font loads, and the console has no error.
  • Presses by click, Enter and Space, the Tab order, and disabled controls.
  • Overlays open, then close by an action, a scrim click and Escape. The focus goes back.
  • Selection controls, tabs, navigation, the slider, text fields, snackbars and tooltips.

CI:

  • The browser-tests job exports the example once for each web runtime. It runs the suite in Chromium, Firefox and WebKit (c4dc7f0, 2caf52a).
  • release.yml and release-manual.yml run the same job when no CI result exists for the commit (20713c5).
  • CI run on 2caf52a: 891 tests passed on each runtime (297 × 3 engines), on the first try.

Benchmark

@rootnative/web 0.0.8 against react-native-web 0.21.4: two production exports of one tree, 10 runs each, 4x CPU slowdown, 1280 × 800, medians. The example is on 0.0.9 now. 0.0.9 changes only ScrollView snapping and the role of TextInput.

  • The HTML of the export is 49 % smaller (43 % with gzip). The JS is 2 % smaller.
  • At load, on each of 7 routes, script time is 9 to 20 % lower, and main-thread task time is 11 to 20 % lower.
  • At load, style recalc is 11 to 67 % lower on 6 of 7 routes. On /text-field it's 74 % higher. The multiline TextInput has field-sizing: content, so the browser reads the font in the style pass, not in the layout pass. The sum of style and layout time there is 10 % lower (128 against 142 ms).
  • During interactions, script time is the same or lower. Typing in a text field takes 42 % less script time.
  • Two interactions do more style work: 5 menu cycles (+90 %, 55 → 105 ms) and 12 button presses (+54 %, 72 → 111 ms). Without the CPU slowdown, that's about 2 to 3 ms for each menu cycle. The cause is in the runtime, not in the components, so this PR doesn't change it.

Not in this PR

  • The Slider moves its thumb through React state, one render for each pixel. A shared value would help on each runtime.
  • One server-side React warning on /i18n (hreflang). I didn't compare it with react-native-web yet.
  • hitSlop on a real touch device, and vertical overflow at the bottom edge of a page.
  • The web Jest projects of components and seo still run on react-native-web. The browser tests cover both runtimes.

After the merge

The merge deploys the docs and the demo, so release 0.0.4 right after it. The release notes need these lines:

  • The RTL fix on main (7e77103).
  • hitSlop on the web.
  • The scrim fix.
  • The search landmark.

@raajnadar raajnadar changed the title Run the example on @rootnative/web Fix RTL on a web runtime that swaps sides, and run the example on @rootnative/web Nov 23, 2026
@raajnadar raajnadar changed the title Fix RTL on a web runtime that swaps sides, and run the example on @rootnative/web Fix RTL and hitSlop for a web runtime, and run the example on @rootnative/web Nov 23, 2026
@raajnadar raajnadar changed the title Fix RTL and hitSlop for a web runtime, and run the example on @rootnative/web Run the example on @rootnative/web, and fix hitSlop, scrims and the search landmark on the web Nov 27, 2026
@raajnadar
raajnadar merged commit 283f018 into main Nov 27, 2026
8 checks passed
@raajnadar
raajnadar deleted the chore/example-on-rootnative-web branch November 27, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant