Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Render the correct logo for the active scheme when logo is minimized #57

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

OsamaSayegh
Copy link
Member

There's currently a bug where if you use the color scheme toggler to switch to the opposite color mode of your system preference, i.e. enable light mode when your system preference is dark and vice versa, the header logo renders the version matching your system preference instead of the selected choice made via the toggler the next time the logo is minimized or expanded (e.g. when scrolling in a long topic).

The bug occurs because when you switch your color scheme via the toggler component, the component updates all the relevant DOM elements that are currently in-view, but subsequent changes to the DOM made by the app, e.g. when the header logo is minimized/expanded, aren't aware of the new choice and resort to the system preference.

This PR fixes the bug by adding a hook to the header logo that gets called when the logo is minimized/expanded and making sure the user's scheme choice is applied to the logo when it's re-rendered.

Internal topic: t/144688.

Copy link

@martin-brennan martin-brennan left a comment

Choose a reason for hiding this comment

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

Nice one!

@OsamaSayegh OsamaSayegh merged commit e33db19 into main Dec 31, 2024
4 checks passed
@OsamaSayegh OsamaSayegh deleted the fix/correct-logo-version-on-scroll branch December 31, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants