mirror of
https://github.com/penpot/penpot.git
synced 2026-03-15 15:05:58 +00:00
Two related issues that could cause crashes during fast navigation in the dashboard: 1. grid.cljs: On drag-start, a temporary counter element is appended to the file card node for the drag ghost image, then scheduled for removal via requestAnimationFrame. If the user navigates away before the RAF fires, React unmounts the section and removes the card node from the DOM. When the RAF fires, item-el.removeChild(counter-el) throws because counter-el is no longer a child. Fixed by guarding the removal with dom/child?. 2. sidebar.cljs: Keyboard navigation handlers used ts/schedule-on-idle (requestIdleCallback with a 30s timeout) to focus the newly rendered section title after navigation. This left a very wide window for the callback to fire against a stale DOM after a subsequent navigation. Additionally, the idle callbacks were incorrectly passed as arguments to st/emit! (which ignores non-event values), making the scheduling an accidental side effect. Fixed by replacing all occurrences with ts/schedule (setTimeout 0), which is sufficient to defer past the current render cycle, and moving the calls outside st/emit!. Signed-off-by: Andrey Antukh <niwi@niwi.nz>