Skip to content

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

Merged
merged 12 commits into from
Jul 27, 2025

Conversation

byseif21
Copy link
Contributor

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.

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label May 20, 2025
@Miodec
Copy link
Member

Miodec commented May 29, 2025

This change will cause multiple calls to refreshCustomButtons / refreshPresetButtons on first load. This needs to be done another way.

byseif21 added 3 commits May 30, 2025 00:44
Added themeUIInitialized flag to avoid multiple calls to refreshCustomButtons and refreshPresetButtons. Ensures proper state reset only when necessary.
@byseif21
Copy link
Contributor Author

This change will cause multiple calls to refreshCustomButtons / refreshPresetButtons on first load. This needs to be done another way.

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!

@Miodec Miodec added the waiting for review Pull requests that require a review before continuing label Jun 16, 2025
@Miodec
Copy link
Member

Miodec commented Jun 23, 2025

How about calling fillPresetButtons and fillCustomButtons in Settings.fillSettingsPage, then calling updateActiveButton in Settings.update?

@Miodec Miodec added waiting for update Pull requests or issues that require changes/comments before continuing and removed waiting for review Pull requests that require a review before continuing labels Jun 23, 2025
@github-actions github-actions bot removed the waiting for update Pull requests or issues that require changes/comments before continuing label Jun 24, 2025
@byseif21
Copy link
Contributor Author

How about calling fillPresetButtons and fillCustomButtons in Settings.fillSettingsPage, then calling updateActiveButton in Settings.update?

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 :( .

@byseif21 byseif21 marked this pull request as draft June 24, 2025 03:38
byseif21 added 2 commits July 15, 2025 20:33
…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.
@byseif21 byseif21 marked this pull request as ready for review July 15, 2025 19:41
@github-actions github-actions bot added the waiting for review Pull requests that require a review before continuing label Jul 15, 2025
@byseif21 byseif21 changed the title fix: auto-refresh themes UI when navigating to settings page (@byseif21) fix(settings): ensure themes UI is always up-to-date when renavigating (@byseif21) Jul 15, 2025
Copy link
Member

@Miodec Miodec left a comment

Choose a reason for hiding this comment

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

Thanks

@Miodec Miodec merged commit e5b0978 into monkeytypegame:master Jul 27, 2025
14 checks passed
@github-actions github-actions bot removed the waiting for review Pull requests that require a review before continuing label Jul 27, 2025
Miodec added a commit that referenced this pull request Jul 27, 2025
@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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend User interface or web stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants