Skip to content

fix(portal): forward the reduce motion preference and match queued update keys - #5124

Merged
satya164 merged 2 commits into
callstack:mainfrom
konstmar:portal-context-fixes
Sep 16, 2026
Merged

satya164 merged 2 commits into
callstack:mainfrom
konstmar:portal-context-fixes

Conversation

@konstmar

@konstmar konstmar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Motivation

1. Reduce Motion is ignored inside a portal

Portal re-provides the settings, locale and theme contexts to its children, but not ReduceMotionContext, so useReduceMotion() falls back to false. The fix forwards it too.

2. PortalHost.update() could update the wrong portal

While operations are queued, update() replaces a matching queued mount or update - but it only compared the key on updates, so it could overwrite a different portal's queued mount. The fix compares the key for both.

Related issue

Context: Notion

Screenshots / Videos

Nothing visual to capture.

Test plan

  • yarn test src/components/__tests__/Portal.test.tsx - 5 passed, including a new test asserting useReduceMotion() reads true inside a Portal. Fails on main.
  • yarn typecheck, yarn lint, yarn test (680 passed) - all pass.

Konstantin Marushchak added 2 commits September 15, 2026 10:07
Re-provide `ReduceMotionContext` in `Portal`, alongside the settings, locale and
theme contexts already forwarded across the portal boundary, so portal content
stops falling back to the context default of `false`.
Compare the key when looking up the queued `mount` to replace, so an update that
arrives before the `PortalManager` ref is attached no longer overwrites an
unrelated queued portal.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fixes are correct, preserve existing behavior, and include appropriate regression coverage for the reachable case.

Pull request overview

Fixes context preservation and queued update matching across the Portal boundary.

Changes:

  • Forwards reduced-motion preferences to portal content.
  • Matches queued mounts and updates by portal key.
  • Adds regression coverage for reduced motion.
File summaries
File Description
src/components/Portal/PortalHost.tsx Corrects queued operation lookup.
src/components/Portal/Portal.tsx Re-provides reduced-motion context.
src/components/__tests__/Portal.test.tsx Tests reduced motion inside portals.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@k0ndee k0ndee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! @satya164

@satya164 satya164 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@satya164
satya164 merged commit 84529e0 into callstack:main Sep 16, 2026
8 of 13 checks 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.

4 participants