fix: keep the selection box on the crosswalk it is drawn around
The box measured state.layers, which is the last compiled output and does not change while editing. The zebra is drawn from the preview, so it slid out from under its own box on every drag and only caught up after a recompile. Reading the preview when one exists puts them back on the same geometry. A null preview layer already means "back to baseline", which is what the fallback says. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4b70b0221d
commit
8a039f47ab
1 file changed
+8
-2
@@ -188,9 +188,15 @@ function App() {
|
||||
if (!directEditEnabled || !element || !state) return null;
|
||||
const handle = crosswalkHandleFor(element, state.compiled.model.roads, editHandles);
|
||||
if (!handle?.editable) return null;
|
||||
const bounds = orientedBoundsOf(groupMembers(state.layers.crosswalks?.features ?? [], element.elementId));
|
||||
// Read the preview when there is one. `state.layers` is the last *compiled*
|
||||
// output and does not move during editing, so measuring the box there left it
|
||||
// behind at the baseline while the zebra itself — drawn from the preview —
|
||||
// slid out from under it. A null preview layer means "back to baseline",
|
||||
// which is what the fallback expresses.
|
||||
const drawn = preview?.crosswalks ?? state.layers.crosswalks;
|
||||
const bounds = orientedBoundsOf(groupMembers(drawn?.features ?? [], element.elementId));
|
||||
return bounds ? { handleId: handle.handleId, bounds } : null;
|
||||
}, [element, editHandles, state]);
|
||||
}, [element, editHandles, state, preview]);
|
||||
const sessionRef = useRef<EditSession | null>(null);
|
||||
if (directEditEnabled && !sessionRef.current) sessionRef.current = new EditSession();
|
||||
// Per-frame drag feedback reaches the panel through this rather than through
|
||||
|
||||
Reference in new issue
Block a user