Skip to content

fix: move ComponentEx off legacy React context onto MainContext (LAZ-1698) - #24980

Open
ecemooo wants to merge 5 commits into
masterfrom
laz-1698-legacy-context
Open

ecemooo wants to merge 5 commits into
masterfrom
laz-1698-legacy-context

Conversation

@ecemooo

@ecemooo ecemooo commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

https://linear.app/nexus-mods/issue/LAZ-1698/clear-the-react-deprecation-warnings-out-of-the-renderer-tests

Summary

Our components stop using React's legacy context, which React 19 removes. ComponentEx and the classes that declared their own context now read MainContext, which holds the same api, menuLayer and getModifiers, so the this.context reads across the app don't change. Nothing changes for users.

  • Overlays: react-bootstrap's OverlayTrigger draws its overlay as a separate React root, which MainContext doesn't reach. MainContextOverlayTrigger hands the overlay its trigger's MainContext, so a menu in a popover in a dialog opens above the dialog. Our OverlayTrigger, TooltipControls and the changelog button use it. Anywhere else, MainProvider fills in MainContext's default value, so an overlay still gets the app's api.
  • Dialogs: Modal passes its own menu layer down through MainContext, so menus opened in a dialog still sit above it.
  • Extensions: extensions that read legacy context keep working, inside dialogs too. That includes classes that copy ComponentEx.contextTypes, and ComponentEx subclasses that declare contextTypes of their own.
  • Leftover warnings: a <p> inside a <p> in Game details, BBCode tables without a <tbody>, and a test mock that couldn't take a ref.
  • Test check: a test now fails when React warns about our code using legacy context, nesting elements HTML doesn't allow, or giving a ref to a function component. react-bootstrap's own warnings don't count.

FormFeedback keeps legacy context: it reads react-bootstrap's FormGroup, which has no other way to share it.

Evidence

  • Before: the renderer tests logged 46 React warnings, about 20 of them legacy context or other warnings from our code.
    After: 30. The rest are findDOMNode and defaultProps (the other LAZ-1698 PRs fix those) and react-bootstrap's own. All renderer tests pass.
  • In the app:
    • Mods, Downloads, Extensions, Settings and Profiles render.
    • A download's right-click menu opens on the menu layer.
    • The Browse Extensions dialog renders, with its own menu layer.
    • Only react-bootstrap components still log legacy-context warnings.

Merge Danger

Door: two-way. Reverting brings back legacy context.

Blast Radius: wide. Every class component built on ComponentEx gets its context a new way. If one ended up with no MainContext value, it would have no api. Watch for menus in dialogs, overlays and popovers, and extension UIs.

For extension authors: a menu inside a popover from react-bootstrap's own OverlayTrigger, inside a dialog, now opens behind the dialog. Nothing in the repo does this.

@ecemooo ecemooo self-assigned this Nov 19, 2026
@ecemooo
ecemooo marked this pull request as ready for review November 19, 2026 12:02
@ecemooo
ecemooo requested a review from a team as a code owner November 19, 2026 12:02
Comment thread src/renderer/test-setup.mts Resolved
Comment thread src/renderer/test-setup.mts Resolved
@ecemooo
ecemooo requested a review from r1chm8 November 19, 2026 16:11
r1chm8
r1chm8 previously approved these changes Nov 19, 2026

@r1chm8 r1chm8 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.

Thanks, all the earlier points check out. One small typing note inline, not blocking.

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.

2 participants