Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/default-coordinate-system-selection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spatialdata/vis": patch
---

Auto-select the coordinate system when a SpatialData object has exactly one. Previously the picker started unselected (showing "Select a coordinate system") even when there was only one choice, and a separate effect would eagerly pick the first of several. Now selection defaults only in the unambiguous single-coordinate-system case; multi-system datasets still require an explicit choice.
16 changes: 8 additions & 8 deletions packages/vis/src/SpatialCanvas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,16 @@ function SpatialCanvasInner({
vw,
]);

useEffect(() => {
if (coordinateSystems.length > 0 && !coordinateSystem) {
actions.setCoordinateSystem(coordinateSystems[0]);
}
}, [coordinateSystems, coordinateSystem, actions]);

useEffect(() => {
actions.reset();
if (coordinateSystem && coordinateSystems.includes(coordinateSystem)) {
actions.setCoordinateSystem(coordinateSystem);
const nextCoordinateSystem =
coordinateSystem && coordinateSystems.includes(coordinateSystem)
? coordinateSystem
: coordinateSystems.length === 1
? coordinateSystems[0]
: null;
if (nextCoordinateSystem) {
actions.setCoordinateSystem(nextCoordinateSystem);
}
}, [coordinateSystem, coordinateSystems, actions]);

Expand Down
Loading