Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "Simplify Widget class constructor (#9815)"
This reverts commit 600fb9c.
  • Loading branch information
ibgreen authored Oct 14, 2025
commit c033a11f8ff2855d044473fc5554e2225ee3d4ef
2 changes: 1 addition & 1 deletion modules/core/src/lib/tooltip-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TooltipWidget extends Widget<TooltipWidgetProps> {
lastViewport?: Viewport;

constructor(props: TooltipWidgetProps = {}) {
super(props);
super(props, TooltipWidget.defaultProps);
this.setProps(props);
}

Expand Down
8 changes: 2 additions & 6 deletions modules/core/src/lib/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ export abstract class Widget<
deck?: Deck<ViewsT>;
rootElement?: HTMLDivElement | null;

constructor(props: PropsT) {
this.props = {
// @ts-expect-error `defaultProps` may not exist on constructor
...(this.constructor.defaultProps as Required<PropsT>),
...props
};
constructor(props: PropsT, defaultProps: Required<PropsT>) {
this.props = {...defaultProps, ...props};
// @ts-expect-error TODO(ib) - why is id considered optional even though we use Required<>
this.id = this.props.id;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/compass-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CompassWidget extends Widget<CompassWidgetProps> {
viewports: {[id: string]: Viewport} = {};

constructor(props: CompassWidgetProps = {}) {
super(props);
super(props, CompassWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/context-menu-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class ContextMenuWidget extends Widget<ContextMenuWidgetProps> {
pickInfo: PickingInfo | null = null;

constructor(props: ContextMenuWidgetProps) {
super(props);
super(props, ContextMenuWidget.defaultProps);
this.pickInfo = null;
this.setProps(this.props);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/fps-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class FpsWidget extends Widget<FpsWidgetProps> {
private _lastFps: number = -1;

constructor(props: FpsWidgetProps = {}) {
super(props);
super(props, FpsWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/fullscreen-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class FullscreenWidget extends Widget<FullscreenWidgetProps> {
fullscreen: boolean = false;

constructor(props: FullscreenWidgetProps = {}) {
super(props);
super(props, FullscreenWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/geocoder-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class GeocoderWidget extends Widget<GeocoderWidgetProps> {
geocoder: Geocoder = CoordinatesGeocoder;

constructor(props: GeocoderWidgetProps = {}) {
super(props);
super(props, GeocoderWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/gimbal-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class GimbalWidget extends Widget<GimbalWidgetProps> {
viewports: {[id: string]: Viewport} = {};

constructor(props: GimbalWidgetProps = {}) {
super(props);
super(props, GimbalWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/info-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class InfoWidget extends Widget<InfoWidgetProps> {
viewport?: Viewport;

constructor(props: InfoWidgetProps) {
super(props);
super(props, InfoWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/loading-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class LoadingWidget extends Widget<LoadingWidgetProps> {
loading = true;

constructor(props: LoadingWidgetProps = {}) {
super(props);
super(props, LoadingWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/reset-view-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ResetViewWidget<ViewsT extends ViewOrViews = null> extends Widget<
placement: WidgetPlacement = 'top-left';

constructor(props: ResetViewWidgetProps<ViewsT> = {}) {
super(props);
super(props, ResetViewWidget.defaultProps as Required<ResetViewWidgetProps<ViewsT>>);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/scale-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ScaleWidget extends Widget<ScaleWidgetProps> {
scaleText: string = '';

constructor(props: ScaleWidgetProps = {}) {
super(props);
super(props, ScaleWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/screenshot-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ScreenshotWidget extends Widget<ScreenshotWidgetProps> {
placement: WidgetPlacement = 'top-left';

constructor(props: ScreenshotWidgetProps = {}) {
super(props);
super(props, ScreenshotWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/splitter-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class SplitterWidget extends Widget<SplitterWidgetProps> {
placement = 'fill' as const;

constructor(props: SplitterWidgetProps) {
super(props);
super(props, SplitterWidget.defaultProps);
}

setProps(props: Partial<SplitterWidgetProps>) {
Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/stats-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class StatsWidget extends Widget<StatsWidgetProps> {
_stats: Stats;

constructor(props: StatsWidgetProps = {}) {
super(props);
super(props, StatsWidget.defaultProps);
this._formatters = {...DEFAULT_FORMATTERS};
this._resetOnUpdate = {...this.props.resetOnUpdate};
this._stats = this.props.stats;
Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/theme-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ThemeWidget extends Widget<ThemeWidgetProps> {
themeMode: 'light' | 'dark' = 'dark';

constructor(props: ThemeWidgetProps = {}) {
super(props);
super(props, ThemeWidget.defaultProps);
this.themeMode = this._getInitialThemeMode();
this.setProps(this.props);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/timeline-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TimelineWidget extends Widget<TimelineWidgetProps> {
};

constructor(props: TimelineWidgetProps = {}) {
super(props);
super(props, TimelineWidget.defaultProps);
this.currentTime = this.props.initialTime ?? this.props.timeRange[0];
this.setProps(this.props);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/view-selector-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ViewSelectorWidget extends Widget<ViewSelectorWidgetProps> {
viewMode: ViewMode;

constructor(props: ViewSelectorWidgetProps = {}) {
super(props);
super(props, ViewSelectorWidget.defaultProps);
this.viewMode = this.props.initialViewMode;
this.setProps(this.props);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/widgets/src/zoom-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
viewports: {[id: string]: Viewport} = {};

constructor(props: ZoomWidgetProps = {}) {
super(props);
super(props, ZoomWidget.defaultProps);
this.setProps(this.props);
}

Expand Down
Loading