Skip to content

fix: dedupe theme core <link> in useThemeCore#262

Merged
arbrandes merged 1 commit into
openedx:mainfrom
arbrandes:arbrandes/fix-double-injection
May 14, 2026
Merged

fix: dedupe theme core <link> in useThemeCore#262
arbrandes merged 1 commit into
openedx:mainfrom
arbrandes:arbrandes/fix-double-injection

Conversation

@arbrandes
Copy link
Copy Markdown
Contributor

Description

Under React StrictMode the useThemeCore effect ran twice on mount and appended a second core stylesheet after the variant <link>, which let core :root declarations override the variant for any custom properties they happened to share. The effect now looks for an existing link[data-theme-core="true"] first: if its href matches the target URL it reuses it, and if the URL has changed it removes the stale link before appending the new one. This mirrors the dedup pattern already used by useThemeVariants.

Closes #261

LLM usage notice

Built with assistance from Claude.

Under React StrictMode the effect ran twice on mount and appended a
second core stylesheet after the variant link, letting core :root
declarations win over variants that shared the same custom properties.

Closes openedx#261

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@diana-villalvazo-wgu diana-villalvazo-wgu left a comment

Choose a reason for hiding this comment

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

🚀

@arbrandes arbrandes merged commit 5df93b1 into openedx:main May 14, 2026
5 checks passed
@arbrandes arbrandes deleted the arbrandes/fix-double-injection branch May 14, 2026 16:19
@openedx-semantic-release-bot
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-alpha.47 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useThemeCore double-injects core <link> under StrictMode, can override variant :root tokens

4 participants