Skip to content

Conversation

@johanrd
Copy link
Contributor

@johanrd johanrd commented Jan 28, 2026

Fixes reactivity issue where restore() on preferences would not trigger updates in plugins with @cached getters (like ColumnVisibility.visibleColumns).

Problem

TrackedPreferences.plugins and TrackedPluginPrefs.columns were regular Maps. When restore() replaced entries, cached getters continued watching the old TrackedMap instances and never invalidated.
## Solution

  1. Use TrackedMap for plugins and columns containers so .set() triggers tracking
  2. Add non-mutating getters (getPlugin, getColumn) for read/delete paths to avoid Glimmer's "mutation during render" error
    ## Test changes
    Updated column-reordering tests to remove ColumnVisibility from expected persisted data. Previously, just reading a plugin's preferences would create empty entries that got serialized. Now only plugins that write data appear in persisted output—this is the correct behavior since empty preferences shouldn't be persisted.

  The `plugins` and `columns` Maps in TrackedPreferences were regular
  Maps, causing restore() to silently fail to trigger reactivity.
  Plugins with @cached getters (like ColumnVisibility.visibleColumns)
  would not update when preferences were restored.

  Changes:
  - Change `plugins` and `columns` from Map to TrackedMap
  - Add non-mutating getters (getPlugin/getColumn) for read operations
    to avoid "update during render" errors
  - Update preferences.forColumn().get() and forTable().get() to use
    non-mutating getters

  Behavior change: Empty plugin preferences are no longer persisted.
  Previously, reading preferences (without writing) would create empty
  entries that were then serialized. Now only plugins that actually
  write preferences data will appear in the persisted output.
@johanrd
Copy link
Contributor Author

johanrd commented Jan 28, 2026

this can be closed if #150 is merged.

Copy link
Contributor

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

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

lgtm , ty

@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Jan 28, 2026
@NullVoxPopuli NullVoxPopuli merged commit 9a51906 into universal-ember:main Jan 28, 2026
12 of 14 checks passed
@github-actions github-actions bot mentioned this pull request Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants