Skip to content

chore: drop the addEventListener workaround now that Storybook 11.0.0-beta.1 guards it - #966

Merged
dannyhw merged 2 commits into
nextfrom
chore/remove-addeventlistener-workaround
Nov 10, 2026
Merged

dannyhw merged 2 commits into
nextfrom
chore/remove-addeventlistener-workaround

Conversation

@dannyhw

@dannyhw dannyhw commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #958.

storybookjs/storybook#37183 ("Preview API: Skip the landmark navigation listener in RN") shipped in storybook@11.0.0-beta.1. It's in the release notes, and the published package calls addEventListener?.("react-aria-landmark-navigation", …). To check, I extracted npm pack storybook@11.0.0-beta.1 and ran grep -rl 'addEventListener?.("react-aria-landmark-navigation"' package/dist. It matches dist/preview/_chunks/runtime-*.js and dist/_browser-chunks/chunk-*.js. With that guard in Storybook itself, our workaround isn't needed.

Changes

  • packages/react-native/src/Start.tsx: removed the setupListeners() override in ReactNativePreview that briefly stubbed globalThis.addEventListener, along with its comment and TODO. renderSelection and teardownRender are unchanged.

  • storybook and @storybook/* dependencies and devDependencies are now ^11.0.0-beta.1 (via pnpm update-storybook-deps --version '^11.0.0-beta.1'), and the lockfile is updated. The lockfile loses some entries because beta.1 bundles its test libraries (Test: Bundle the test libraries and their types, upgrade to Vitest 5 storybook#37143) and makes react-docgen optional (React: Make react-docgen optional and drop builder docgen deps from the default install storybook#37141).

  • Peer floors are raised from ^11.0.0-beta.0 to ^11.0.0-beta.1. That's storybook in every package, plus @storybook/react in addon-ondevice-notes. No other peers changed.

  • A patch changeset for @storybook/react-native.

  • @storybook/mcp is updated from ^10.6.0 to ^11.0.0-beta.1. update-storybook-deps had it on its ignore list from when it had its own 0.x versions. Since 10.6 it's released alongside storybook, so the script now includes it. Only @storybook/addon-react-native-server is still skipped.

  • The select-story MCP tool's description pointed agents at list-all-documentation, a tool @storybook/mcp already calls docs-list (in 10.6.6 too). It now says docs-list with withStoryIds: true.

Checks

All of these pass:

  • pnpm install
  • pnpm build
  • pnpm test: packages/react-native 79 tests, including storySorts.test.ts and updateView.test.ts, which failed without the workaround; expo-example 32 passed, 2 skipped; plus the tests package (node test runner), ondevice-actions and react-native-ui
  • pnpm check:types
  • pnpm lint
  • pnpm format:check
  • pnpm repo:lint

Device testing

I ran examples/expo-example against this branch's Metro on an iOS 27 simulator (iPhone 17e) and an Android 15 emulator (Pixel 9), both using SDK 58 / RN 0.88 dev builds.

  • The served iOS and Android bundles contain Storybook 11.0.0-beta.1's guarded addEventListener?.("react-aria-landmark-navigation", …) and none of the removed stub.
  • On both platforms the app starts without errors. The only warnings are the existing color-control ones, which next also shows.
  • Selecting a story through the channel server (select-story-sync) and in the on-device story list (Boolean / On) renders it.
  • An updateStoryArgs event re-renders the story with the new args.

MCP server

With @storybook/mcp 11.0.0-beta.1 I started Metro for examples/expo-example and called the server at http://localhost:7007/mcp directly. initialize and tools/list work, and tools/list returns docs-list, docs-show, docs-show-story, get-storybook-story-instructions and select-story.

  • docs-list lists the example's components.
  • docs-show (controlexamples-controlexample) returns its props.
  • docs-show-story (controlexamples-controlexample--example) returns the story snippet.
  • select-story (controlexamples-boolean--on) reports the story as selected.

After the bump, pnpm build, test, check:types, lint, format:check and repo:lint all pass.

…-beta.1 guards it

storybookjs/storybook#37183 shipped in 11.0.0-beta.1, so PreviewWithSelection no longer calls window.addEventListener when the global doesn't have it. Remove the setupListeners override, update Storybook to 11.0.0-beta.1 and raise the storybook peer floors to it.
@changeset-bot

changeset-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c7c8197

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@storybook/react-native Patch
@storybook/addon-ondevice-actions Patch
@storybook/addon-ondevice-backgrounds Patch
@storybook/addon-ondevice-controls Patch
@storybook/addon-ondevice-notes Patch
@storybook/react-native-theming Patch
@storybook/react-native-ui-common Patch
@storybook/react-native-ui-lite Patch
@storybook/react-native-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…k packages

@storybook/mcp is released in step with storybook now, so update-storybook-deps no longer skips it. Also point the select-story tool at docs-list, the current name of the documentation list tool.
@dannyhw
dannyhw marked this pull request as ready for review November 10, 2026 00:13
@dannyhw
dannyhw merged commit 5e9cd39 into next Nov 10, 2026
1 check passed
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