Repository navigation
[Map layers]: add offlineMode option to MapLayerOptions - #1831
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
An in-flight source request can continue after switching to read-only mode, violating the offline-loading guarantee.
4 open findings
What changed in this PR
Adds an optional read-only mode to keep Map Layers usable offline while preventing network-dependent configuration changes.
Changes:
- Hides or disables attach, detach, sign-in, reorder, settings, and provider controls.
- Preserves visibility, transparency, zoom, color, and sub-layer controls.
- Skips source loading and adds read-only tests and documentation.
| File | Description |
|---|---|
MapLayersList.tsx |
Hides attach controls. |
MapLayerSettingsMenu.tsx |
Hides detach action. |
MapLayerManager.tsx |
Propagates read-only state. |
MapLayerItem.tsx |
Hides selection and authentication controls. |
MapLayerDroppable.tsx |
Disables reordering and attachment. |
MapLayerActionButtons.tsx |
Hides selection and bulk detach. |
BasemapPanel.tsx |
Disables provider selection. |
Interfaces.ts |
Defines the public option. |
useMapLayerSources.ts |
Skips source loading. |
MapLayerManager.test.tsx |
Tests read-only behavior. |
| Changeset | Documents the new option. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… fix loading state; review nits
mdastous-bentley
left a comment
There was a problem hiding this comment.
readOnly is understandable, but a bit misleading: the widget still lets users change map-layer visibility, transparency, and other display state. “Read-only” usually suggests no changes at all.
offlineMode is a reasonable alternative if the intent is specifically to support offline apps, though it describes the use case rather than the behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@mdastous-bentley Good point |


Summary
Adds an optional
MapLayerOptions.offlineModeflag so desktop apps can keep the Map Layers widget visible while offline instead of hiding it.Today iTwin Studio hides the widget when offline, because attach, base map provider change, sign-in and map settings need the network. With
offlineMode: true:Map layer sources (
MapLayerSources.create,MapLayerPreferences.getSources) are not loaded in offline mode; they load again when the flag switches back tofalse.Compatibility
offlineModeis optional and defaults tofalse; no existing behavior, props or exports change. A test covers that all actions are still shown when it is not set.Usage
Open question
Should offline mode allow switching the base map to "Color fill" (works offline)? This PR disables the provider select entirely to keep the change minimal.
Testing
MapLayerManager.test.tsx(offline mode: hidden actions, layer menu, visibility controls, no source loading, default unchanged).pnpm build,pnpm test,pnpm lint,pnpm format,cspellpass locally.