Skip to content

fix(wrapper): unmount _HTMLGenericModal React content on hide#3717

Merged
rxri merged 1 commit intospicetify:mainfrom
Konsl:patch-1
Mar 1, 2026
Merged

fix(wrapper): unmount _HTMLGenericModal React content on hide#3717
rxri merged 1 commit intospicetify:mainfrom
Konsl:patch-1

Conversation

@Konsl
Copy link
Contributor

@Konsl Konsl commented Mar 1, 2026

we dont need an additional check since unmountComponentAtNode just does nothing if the element is not a React root

code snippet to verify that it works:

Spicetify.PopupModal.display({ title: "HI", content: Spicetify.React.createElement(() => {
    Spicetify.React.useEffect(() => { console.log("mounted"); return () => console.log("unmounted"); });
    return "hi";
}, {}) })

i did verify that it does not crash or anything if content is not a React element

Summary by CodeRabbit

  • Bug Fixes
    • Improved modal cleanup behavior to ensure React components are properly unmounted when modals are hidden, preventing memory leaks and related performance issues.

@coderabbitai
Copy link

coderabbitai bot commented Mar 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c5e920 and 69f6340.

📒 Files selected for processing (1)
  • jsHelper/spicetifyWrapper.js

📝 Walkthrough

Walkthrough

A single line is added to jsHelper/spicetifyWrapper.js in the _HTMLGenericModal.hide function. Before removing the modal element, the change explicitly unmounts React components rendered inside the modal using Spicetify.ReactDOM.unmountComponentAtNode on the <main> element.

Changes

Cohort / File(s) Summary
React Component Cleanup
jsHelper/spicetifyWrapper.js
Added unmountComponentAtNode call on the <main> element to properly clean up React components rendered inside the modal before removal.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Whiskers twitch with glee, for cleanup's done,
React's children tucked in safely, one by one,
No dangling nodes or ghosts that linger long,
A tidy modal now—the code sings true and strong! 🎵

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rxri rxri merged commit d0df3dc into spicetify:main Mar 1, 2026
5 of 6 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.

2 participants