Skip to content

Commit e7863b8

Browse files
committed
Remove 'setBoardOffsets' guard to avoid stale values
1 parent fd1d36c commit e7863b8

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

  • packages/editor/src/components/collab-sidebar

packages/editor/src/components/collab-sidebar/hooks.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,23 +361,21 @@ export function useFloatingBoard( { threads, selectedNoteId, isFloating } ) {
361361

362362
const heights = useSyncExternalStore( store.subscribe, store.getSnapshot );
363363

364-
// Defer rect reads + offset calculation to a rAF so rapid-fire
365-
// changes (ResizeObserver, selection, threads) coalesce into one recalc.
364+
// Recalc is deferred to a rAF; the cleanup cancels the pending frame
365+
// when deps change, so back-to-back updates collapse into one paint.
366366
useEffect( () => {
367367
if ( ! isFloating ) {
368368
return;
369369
}
370370

371371
const rafId = window.requestAnimationFrame( () => {
372-
const { offsets: newOffsets, minHeight } = calculateAllOffsets( {
372+
const { offsets, minHeight } = calculateAllOffsets( {
373373
threads,
374374
selectedNoteId,
375375
blockRects: store.getBlockRects(),
376376
heights,
377377
} );
378-
if ( Object.keys( newOffsets ).length > 0 ) {
379-
setBoardOffsets( newOffsets );
380-
}
378+
setBoardOffsets( offsets );
381379
setCanvasMinHeight( minHeight );
382380
} );
383381

0 commit comments

Comments
 (0)