Skip to content

Comments

feat(widgets): Add controlled mode and state callbacks#9973

Open
chrisgervang wants to merge 4 commits intomasterfrom
chr/widget-state-callbacks
Open

feat(widgets): Add controlled mode and state callbacks#9973
chrisgervang wants to merge 4 commits intomasterfrom
chr/widget-state-callbacks

Conversation

@chrisgervang
Copy link
Collaborator

@chrisgervang chrisgervang commented Jan 30, 2026

Summary

Implements controlled/uncontrolled component pattern for 12 deck.gl widgets, enabling applications to drive widget state from external state management. Adds state props, getter methods, and event callbacks.

Change List

  • Theme/Display: ThemeWidget (themeMode), FullscreenWidget (fullscreen), StatsWidget (collapsed)
  • Timeline: TimelineWidget (time, playing)
  • Navigation: ZoomWidget (onZoom), CompassWidget (onCompassReset), GimbalWidget (onGimbalReset)
  • Geospatial: GeocoderWidget (onGeocode), ResetViewWidget (onReset)
  • Views: ViewSelectorWidget (viewMode), SplitterWidget (split)
  • Notifications: LoadingWidget (onLoadingChange)
  • Documentation: Widget overview with controlled/uncontrolled mode explanation

Closes #9964


Note

Medium Risk
Touches interaction/state logic across many widgets (fullscreen, timeline playback, view selection), so regressions in UI behavior or event handling are possible despite changes being mostly additive and opt-in.

Overview
Adds a controlled/uncontrolled state pattern across multiple @deck.gl/widgets components, introducing new state props (e.g., themeMode, fullscreen, time, playing, collapsed, viewMode, split) plus getter methods, and updates rendering/interaction logic to defer internal state updates when controlled.

Introduces new event callbacks for user actions and state transitions (onZoom, onCompassReset, onGimbalReset, onGeocode, onReset, onLoadingChange, onFullscreenChange, onPlayingChange, onCollapsedChange) and updates docs to describe controlled vs uncontrolled usage and document the new props across widget API pages.

Written by Cursor Bugbot for commit 7e952dd. This will update automatically on new commits. Configure here.

Cursor Bugbot found 1 potential issue for commit 7e952dd

Implement controlled/uncontrolled component pattern for 12 widgets (ThemeWidget, FullscreenWidget, TimelineWidget, ZoomWidget, CompassWidget, GimbalWidget, GeocoderWidget, ResetViewWidget, ViewSelectorWidget, SplitterWidget, StatsWidget, LoadingWidget). Add state props, getter methods, and callbacks. Update widget overview documentation with controlled/uncontrolled mode explanation.

Closes #9964

Co-Authored-By: Claude (global.anthropic.claude-haiku-4-5-20251001-v1:0) <noreply@anthropic.com>
@chrisgervang chrisgervang requested a review from ibgreen January 30, 2026 18:27
@coveralls
Copy link

coveralls commented Jan 30, 2026

Coverage Status

coverage: 91.091%. remained the same
when pulling 7e952dd on chr/widget-state-callbacks
into 1510545 on master.

@chrisgervang chrisgervang mentioned this pull request Jan 30, 2026
62 tasks
@chrisgervang chrisgervang added this to the v9.3 milestone Feb 2, 2026
Resolve conflict in stats-widget.tsx: keep _collapsed naming for controlled
mode internal state, use _getStats() method from master.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove redundant _playing assignments in timeline-widget start()/stop()
- Remove redundant updateHTML() calls after super.setProps() in multiple widgets
- Fix IconMenu to support controlled mode via selectedItem prop

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

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 and found 1 potential issue.

}

setProps(props: Partial<TimelineWidgetProps>): void {
const {time: prevTime, playing: prevPlaying} = this.props;
Copy link

Choose a reason for hiding this comment

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

Unused variable prevTime in setProps method

Low Severity

The variable prevTime is destructured from this.props but never used in the setProps method. Only prevPlaying is used (line 96). This dead code should be removed by changing to const {playing: prevPlaying} = this.props;.

Fix in Cursor Fix in Web

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.

feat(mapbox): Add Controlled Mode and State Callbacks to Widgets

2 participants