Skip to content

Fix: Restore palette selection after theme switch#5892

Open
rashi-cse wants to merge 2 commits intosugarlabs:masterfrom
rashi-cse:theme-ui-sync-fix
Open

Fix: Restore palette selection after theme switch#5892
rashi-cse wants to merge 2 commits intosugarlabs:masterfrom
rashi-cse:theme-ui-sync-fix

Conversation

@rashi-cse
Copy link
Contributor

@rashi-cse rashi-cse commented Feb 23, 2026

Fix: Restore active palette state after theme change #5825 (Issue)

Summary

This PR fixes a UI synchronization issue where switching themes caused the active palette selection to lose its highlighted state until a hover interaction occurred.

Changes

  • Stored selector <tr> elements in a selectorRows array to preserve state
  • Converted palette name to group index using MULTIPALETTES
  • Cleared and rebuilt palette selectors during theme change
  • Restored selection using showSelection() and makePalettes()
  • Removed dependency on hover to refresh the palette UI

Result

  • Active palette remains highlighted after theme switch
  • No hover interaction required to restore UI state
  • Search bar and palette behavior remain consistent
  • No visual regression observed

Preview of the change:

preview.mov

- Store selector TR elements in selectorRows array for state restoration
- Convert palette NAME to group INDEX using MULTIPALETTES
- Clear palette DOM and rebuild selectors on theme change
- Restore selection using showSelection() and makePalettes()
- No longer requires hover to update palette UI
@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@zealot-zew
Copy link
Contributor

Good fix, maybe you could handle the theme change for blocks too

@rashi-cse
Copy link
Contributor Author

@zealot-zew Thanks! Good suggestion.
This PR focuses on the palette state issue, but syncing block colors with theme change makes sense too. I’ll look into that as a follow-up improvement.

@rashi-cse
Copy link
Contributor Author

rashi-cse commented Mar 5, 2026

Hi @Commanderk3 and @zealot-zew,
Thanks for the suggestion about updating the block colors as well.

From investigating the theme switch flow, it seems that when the theme changes, platformColor is updated but the palette color constants (PALETTEFILLCOLORS, PALETTESTROKECOLORS, etc.) are not re-populated, and existing workspace blocks are not re-rendered.

I started working on this issue but ran into some unexpected behavior with block rendering and palette interaction. I'll pause work on this for now and may revisit later if needed.

Thanks!

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