-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(settings): ensure themes UI is always up-to-date when renavigating (@byseif21) #6581
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(settings): ensure themes UI is always up-to-date when renavigating (@byseif21) #6581
Conversation
This change will cause multiple calls to |
Added themeUIInitialized flag to avoid multiple calls to refreshCustomButtons and refreshPresetButtons. Ensures proper state reset only when necessary.
hey mio check this approach and tell me what do you think of it ! I’ve added a flag to track whether the UI has already been set up. Now refreshThemeUI() skips redundant work unless the state is explicitly reset, I kept thinking for other ways like an event-based approach or refactor the theme UI with lifecycle methods, but this is the one with minimal changes I feel, so let me know what do you feel about that and if you spot any edge cases I might’ve missed! |
How about calling |
I did it thinking it would be the best we could do here, but then I noticed that we can't make this work without not calling fillPresetButtons inside update() atp to keep favorites in sync, not just updateActiveButton. That means extra DOM work and redundancy. I have been thinking about that for a while so Idk what to do here actually! I'll rethink it again tom :( . |
…dant calls - new updateThemeUI function to handle preset theme button rendering and active theme highlighting in one place. - fillSettingsPage now only initializes custom theme buttons, not preset or active theme buttons. - update only updates the active tab and custom theme inputs, not preset or active theme buttons. - updateThemeUI is called once after both fillSettingsPage and update, ensuring theme UI is updated efficiently and only once per page show. - i feel like this even improves performance a bit settings seems to load faster now idk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@byseif21) (#6581) ### Description When (changing / adding or removing themes from favorite ) via command line or from the current theme button "in page e.g test page" and then navigating to Settings > Themes, the UI does not immediately reflect the current theme changes . The user has to manually refresh the page to see these changes. **Now** UI automatically refreshes to reflect the current theme selection and favorites without requiring a manual page refresh. - Added refreshThemeUI function in theme-picker.ts that updates all theme-related UI components - Called this refresh function in the settings page's beforeShow lifecycle hook to ensure the theme UI is always up-to-date when the page is displayed. **FOR TESTING BEFORE & AFTER:** keep changing themes then navigate to the settings and check and keep doing those things again to verify that the active theme and favorites update. --------- Co-authored-by: Miodec <jack@monkeytype.com>
Description
When (changing / adding or removing themes from favorite ) via command line or from the current theme button "in page e.g test page" and then
navigating to Settings > Themes, the UI does not immediately reflect the current theme changes . The user has to manually refresh the page to see these changes.
Now
UI automatically refreshes
to reflect the current theme selection and favorites without requiring
a manual page refresh.
theme-related UI components
FOR TESTING BEFORE & AFTER:
keep changing themes then navigate to the settings and check and keep doing those things again to verify that the active theme and favorites update.