Skip to content

Let unset delete the key behind a v15_unsetRemovesKey future flag - #481

Open
pjeweb wants to merge 8 commits into
feat/remove-layer-and-feature-sourcefrom
feat/unset-removes-key-future-flag
Open

pjeweb wants to merge 8 commits into
feat/remove-layer-and-feature-sourcefrom
feat/unset-removes-key-future-flag

Conversation

@pjeweb

@pjeweb pjeweb commented Nov 12, 2026

Copy link
Copy Markdown
Member

Summary

Stacked on #478 (feat/remove-layer-and-feature-source); merge that one first. The diff here shows only the flag.

unset(path) is set(path, undefined): the key stays in the state with an undefined value. That state does not survive serialisation and contradicts the state types. In the next major of @mapsight/core, unset will delete the key. Until then the default stays as it is, and hosts can opt in per store.

  • @mapsight/core: createMapsightStore takes a future option with the contract of Decision 012 (v{major}_{behavior}, true means the next major's behaviour now). New flag v15_unsetRemovesKey. With it on, unset(path) deletes the key when its parent is a plain object, with the same result as removeKey. Array elements are still set to undefined, a missing key or parent leaves the state reference unchanged, and a plain set(path, undefined) behaves as before. Without the flag nothing changes.
  • How: unset is still a MAPSIGHT_SET action, now with a marker in meta. The flag is read per store, in the reducer createMapsightStore builds for each controller after path routing; only an unset with a plain-object parent is turned into removeKey. Batches and the controlled(), quiet() and async() wrappers keep the marker. Several stores on one page can use different settings.
  • @mapsight/ui: createOptions.future.v8_unsetRemovesKey is forwarded to the core flag. The name follows the ui major line, as Decision 012 prescribes for createOptions; it assumes ui v8 ships together with core v15.
  • Docs: Decision 012 (flag list, and that core now has a future option with the same contract), the config reference, the action guide with a table of both modes, the Redux architecture and config merge notes. They recommend removeKey and the domain actions for removal today.

Note for reviewers: with the flag on, reducers registered on a controller see MAPSIGHT_REMOVE_KEY instead of MAPSIGHT_SET for such an unset; app reducers still see the original action.

Test plan

  • pnpm --filter @mapsight/core test (385 tests), typecheck, lint (no errors)
  • pnpm --filter @mapsight/ui test (584 tests), typecheck, lint (no errors)
  • pnpm run check
  • Flag off (omitted, {}, false): results pinned against set(path, undefined), including state reference equality
  • Flag on: plain-object, array and missing parents; unset inside a batch and wrapped in controlled(), quiet() and async(); two stores with different settings
  • removeInteractionSelection in both modes; unset of a layer or feature source ends in the same state as removeLayer / removeFeatureSource
  • The ui flag reaches the store

Add a future option to createMapsightStore and forward it from the
ui future flags as v8_unsetRemovesKey. With the flag on, unset(path)
deletes the key of a plain object parent; array elements, missing
parents and a plain set(path, undefined) keep their behavior.
@changeset-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d36e9e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@mapsight/core Minor
@mapsight/ui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

1 participant