Skip to content

Fix MeasureControl custom units never reaching the front-end - #1278

Closed
cpruijsen wants to merge 1 commit into
jupyter-widgets:masterfrom
cpruijsen:fix/issue-1264
Closed

cpruijsen wants to merge 1 commit into
jupyter-widgets:masterfrom
cpruijsen:fix/issue-1264

Conversation

@cpruijsen

Copy link
Copy Markdown

MeasureControl.add_length_unit has no effect. Two independent causes, both in
python/jupyter_leaflet/src/controls/MeasureControl.ts.

The model default is spelled secondar_area_unit, missing the y. Anything reading
secondary_area_unit therefore falls through to undefined regardless of what the user set.

And create_obj builds the Leaflet control with get_options(), which carries the base control
options rather than the measure-specific ones. Custom units synced from Python before the view exists
are in the measure options, so they were never passed. The control is re-initialised with
get_measure_control_options() after construction, which is what applies them.

Both were needed: fixing the typo alone still loses units set before view creation, and
re-initialising alone still cannot see an area unit stored under a misspelled key.

Fixes #1264

Apply merged units (defaults + _custom_units) at view creation so
units added before the control displays are honored; re-initialize the
control on change:_custom_units so add_length_unit/add_area_unit work
after display too. Also fix secondar_area_unit typo in model defaults.

Fixes jupyter-widgets#1264
@cpruijsen

Copy link
Copy Markdown
Author

Closing this one so it does not sit in the queue.

@cpruijsen cpruijsen closed this Oct 1, 2026
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.

Measure control's add_length_unit function doesn't work

1 participant