Skip to content

fix(core): keep the default view and widget id on a prototype - #11114

Merged
chrisgervang merged 7 commits into
masterfrom
chr/view-widget-prototype-id
Nov 21, 2026
Merged

chrisgervang merged 7 commits into
masterfrom
chr/view-widget-prototype-id

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

For #11113

Background

View and Widget write their default id into props, so code that wraps deck.gl can't tell new MapView({id: 'MapView'}) from new MapView(). Layers already keep the default id on the props prototype, so Object.hasOwn(layer.props, 'id') works for them.

Change List

  • View, Widget: default id lives on the props prototype
  • View#makeViewport: sets id explicitly, so Function passed as child of DeckGL react component never called #3259 can't return
  • CustomProjectionView#makeViewport: sets id explicitly
  • View#equals, CustomProjectionView#equals: compare resolved ids
    • new MapView() still equals new MapView({id: 'MapView'}), so nothing rebuilds
  • Widget: {id: undefined} falls back to the default id, in the constructor and setProps
  • Add createPropsWithDefaultId util, shared by View and Widget
  • Unit tests

Verified with yarn lint and the headless tests for core, widgets, react, mapbox and maplibre.


Generated by Claude Code


Note

Low Risk
Refactors default property assignment for views and widgets with no breaking changes to public APIs and extensive test coverage.

Overview
Stores default id values on the prototype of props for View and Widget instances instead of as own properties. This allows consumers and wrapper libraries to distinguish user-provided IDs from class defaults via Object.hasOwn(props, 'id').

The new helper createPropsWithDefaultId establishes prototype-based default IDs during instantiation and updates. To prevent regression when spreading props, makeViewport in View and CustomProjectionView now sets id explicitly, and equality comparisons evaluate resolved IDs.

Reviewed by Cursor Bugbot for commit 9875293. Bugbot is set up for automated code reviews on this repo. Configure here.

Like layer props, `View` and `Widget` now keep their default `id` on the
props prototype, so `Object.hasOwn(props, 'id')` tells a passed id from
the default while `props.id` still reads the resolved id.

- `makeViewport` sets `id` explicitly, since spreading props drops it
- `View#equals` compares resolved ids, so an implicit and an explicit
  default id stay equal

For #11113

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Moves default view and widget IDs onto the props prototype so wrappers can distinguish defaults from explicit IDs.

  • Views and widgets keep default IDs off their props objects.
  • Views keep their IDs when equality checks and viewports are built.

Reviews (4) · Last reviewed commit: "fix(core): use hasOwnProperty instead of..." · Reviewed by Greptile

@coveralls

coveralls commented Nov 14, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 82.444% (+0.007%) from 82.437% — chr/view-widget-prototype-id into master

chrisgervang pushed a commit to visgl/deck.gl-community that referenced this pull request Nov 15, 2026
Needs visgl/deck.gl#11114, which keeps the default view and widget id on
the props prototype. A layer, view or widget now has no id exactly when
Object.hasOwn(props, 'id') is false, so an explicit id equal to the class
default, such as new MapView({id: 'MapView'}), is never renamed.

deck.gl effects take no id, so only an effect a component built gets an
id from its path; a raw <deckEffect> keeps its id.

Until deck.gl releases #11114, a temporary yarn patch applies it to
@deck.gl/[email protected].

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
Comment thread modules/core/src/views/view.ts Resolved
Comment thread modules/core/src/views/view.ts Resolved

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ffa20c3. Configure here.

Comment thread modules/core/src/lib/widget.ts Resolved
…ned id

The constructor drops an undefined id so the default on the props prototype
shows through, but setProps assigned it as an own undefined. Widgets that
reapply props, such as TooltipWidget, then had props.id undefined while id kept
the default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

…xcept

View#equals and CustomProjectionView#equals give both sides their resolved id
and compare with deepEqual, so the new deepEqualExcept helper is removed. The
spread copies only own props, and adding the id back gives both objects the
same keys, so equality is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

chrisgervang pushed a commit that referenced this pull request Nov 21, 2026
Safari 15.0-15.3 lack Object.hasOwn, so the second configure threw there.
getRemovedProps uses Object.prototype.hasOwnProperty.call, as #11114 does, with
the same own-property semantics. A test runs two configures with Object.hasOwn
removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
@ibgreen ibgreen added the bug label Nov 21, 2026
@chrisgervang
chrisgervang merged commit 17085f1 into master Nov 21, 2026
9 checks passed
@chrisgervang
chrisgervang deleted the chr/view-widget-prototype-id branch November 21, 2026 16:30
chrisgervang pushed a commit that referenced this pull request Nov 21, 2026
Takes master's #11114 (squash-merged) for the files this branch stacked on,
keeps this PR's own change, and extends it to setProps: since #11114, setProps
treats an undefined id as the class default, and it now does so for any falsy id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
@chrisgervang chrisgervang mentioned this pull request Nov 22, 2026
29 of 30 tasks
chrisgervang added a commit that referenced this pull request Nov 22, 2026
…React tree (#11271)

For #11036

Replays visgl/deck.gl-community#1077 onto @deck.gl/react, now that #11114
keeps the default view and widget id on the props prototype.

- reconciler/element-ids.ts (new): path-based ids and a dev-only duplicate-id warning
- shared/generated-effect-id.ts (new): marks effects that a component built
- reconciler/config.ts: stores each element's path; hidden clones keep it
- reconciler/utils.ts: prop entries replace JSX elements by final id
- wrappers/factories.tsx: effect components mark their effect
- Removes the dead `needs a stable id` warning
- Unit tests, including fast-check property tests of the id format
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-visgl__deck.gl that referenced this pull request Nov 22, 2026
… at creation (visgl#11267)

* fix(react): reset removed props, and warn about props that only apply at creation

Replays visgl/deck.gl-community#1088 onto @deck.gl/react. visgl#10906 made Deck fall
back to the default for a prop passed as undefined, so the root only resets
props that a render removed, and passes undefined through.

- A prop the last configure had and this one doesn't is sent as its Deck
  default. layers, views, widgets and effects are left out of that spread, so
  views={undefined} can't clear views that a widget such as SplitterWidget set.
- An overlay that doesn't forward JSX views follows the same views rule with
  its views prop alone.
- In development builds, changing deviceProps, gl, debug, touchAction,
  eventRecognizerOptions or _typedArrayManagerProps after creation warns once
  per prop per root, with a link to the DeckGL docs.

The community PR's yarn patch isn't needed: deck.gl builds @deck.gl/core from
source, which includes visgl#10906. Its creation-only test runs in the jsdom react
project, where vi.stubEnv reaches process.env.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): keep device and _canvases when they are removed

A live Deck can't take their defaults. Deck.setProps only swaps in a new
device, so sending null left Deck rendering with its device while its props
said null. _canvases chose single- or multi-canvas mode, and Deck.setProps
asserts that the mode never changes, so sending null threw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): keep device and _canvases passed as undefined

Deck.setProps resets an explicit undefined to its default (visgl#10906), so passing
device or _canvases as undefined hit the same problems as removing them. The
root leaves either out of setProps when it is undefined, as when it is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): don't use Object.hasOwn in the prop-reset helper

Safari 15.0-15.3 lack Object.hasOwn, so the second configure threw there.
getRemovedProps uses Object.prototype.hasOwnProperty.call, as visgl#11114 does, with
the same own-property semantics. A test runs two configures with Object.hasOwn
removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): check a removed callback, generated ids and a creation-only warning in one root

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

---------

Co-authored-by: Claude <[email protected]>
chrisgervang added a commit that referenced this pull request Nov 24, 2026
#11303)

For #11113

- View, Widget: default id lives on the props prototype
- View#makeViewport: set id explicitly, so #3259 can't return
- View#equals: compare resolved ids, so new MapView() still equals new MapView({id: 'MapView'})
- Widget: {id: undefined} falls back to the default id, in the constructor and setProps
- Add createPropsWithDefaultId util, shared by View and Widget
- Unit tests

(cherry picked from commit 17085f1)

Backport to 9.4: drops the CustomProjectionView hunks; that view is not on 9.4.
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

Released in deck.gl 9.4.2, as #11303 on 9.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants