Fix: rename map cursor awareness field to avoid y-codemirror collision

y-codemirror.next uses the awareness 'cursor' field for text editor
cursor positions. Our map cursor tracker was using the same field name,
causing Invalid LatLng errors when the receiving participant tried to
render a CodeMirror cursor object as map coordinates.

Renamed to 'mapCursor' to avoid the collision.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-11 02:58:05 +02:00
parent f7e0f904a9
commit 9e7aa4647d
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9

View file

@ -152,14 +152,14 @@ function CursorTracker({ awareness }: { awareness: YjsState["awareness"] }) {
const localId = awareness.clientID;
const handleMouseMove = (e: L.LeafletMouseEvent) => {
awareness.setLocalStateField("cursor", {
awareness.setLocalStateField("mapCursor", {
lat: e.latlng.lat,
lng: e.latlng.lng,
});
};
const handleMouseOut = () => {
awareness.setLocalStateField("cursor", null);
awareness.setLocalStateField("mapCursor", null);
};
map.on("mousemove", handleMouseMove);
@ -169,10 +169,10 @@ function CursorTracker({ awareness }: { awareness: YjsState["awareness"] }) {
const states = awareness.getStates();
const newCursors = new Map<number, { lat: number; lng: number; color: string; name: string }>();
states.forEach((state, clientId) => {
if (clientId !== localId && state.cursor && state.user) {
if (clientId !== localId && state.mapCursor && state.user) {
newCursors.set(clientId, {
lat: state.cursor.lat,
lng: state.cursor.lng,
lat: state.mapCursor.lat,
lng: state.mapCursor.lng,
color: state.user.color,
name: state.user.name,
});