More misc sync fixes (#1559)
Follow-up to #1555, taking care of a few more rare edge cases found during fuzz testing. ### Change Type <!-- 💡 Indicate the type of change your pull request is. --> <!-- 🤷♀️ If you're not sure, don't select anything --> <!-- ✂️ Feel free to delete unselected options --> <!-- To select one, put an x in the box: [x] --> - [x] `patch` — Bug Fix
This commit is contained in:
parent
0cc91eec62
commit
707ddc876f
2 changed files with 9 additions and 4 deletions
|
@ -1008,7 +1008,6 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|||
if (!withIndices) return EMPTY_ARRAY
|
||||
return this._childIdsCache.get(withIndices, () => withIndices.map(([id]) => id))
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a visitor function for all descendants of a shape.
|
||||
*
|
||||
|
@ -2134,7 +2133,8 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|||
return acc
|
||||
}
|
||||
|
||||
const parent = this.store.get(parentId)!
|
||||
const parent = this.store.get(parentId)
|
||||
if (!parent) return acc
|
||||
acc.push(parent)
|
||||
return this.getAncestors(parent, acc)
|
||||
}
|
||||
|
@ -2152,7 +2152,8 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|||
* @public
|
||||
*/
|
||||
getAncestorsById(id: TLShapeId, acc: TLShape[] = []): TLShape[] {
|
||||
const shape = this.getShapeById(id)!
|
||||
const shape = this.getShapeById(id)
|
||||
if (!shape) return acc
|
||||
return this.getAncestors(shape, acc)
|
||||
}
|
||||
|
||||
|
@ -4697,6 +4698,10 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|||
partial.y = point.y
|
||||
partial.rotation = -this.getPageRotationById(parentId) + (partial.rotation ?? 0)
|
||||
}
|
||||
// a shape cannot be it's own parent. This was a rare issue with frames/groups in the syncFuzz tests.
|
||||
if (partial.parentId === partial.id) {
|
||||
partial.parentId = focusLayerId
|
||||
}
|
||||
return partial
|
||||
}
|
||||
return partial
|
||||
|
|
|
@ -50,7 +50,7 @@ export function getArrowTerminalInArrowSpace(
|
|||
const boundShape = editor.getShapeById(terminal.boundShapeId)
|
||||
|
||||
if (!boundShape) {
|
||||
console.error('Expected a bound shape!')
|
||||
// this can happen in multiplayer contexts where the shape is being deleted
|
||||
return new Vec2d(0, 0)
|
||||
} else {
|
||||
// Find the actual local point of the normalized terminal on
|
||||
|
|
Loading…
Reference in a new issue