Files
flowsint/flowsint-app/src
dextmorgn 58a3c39f0b fix(frontend): fix first-mount data loss in adjust-during-render sync
The react-hooks/set-state-in-effect cleanup earlier in this branch
converted several "sync local form state from loaded data" effects to
the adjust-during-render pattern: track a prevValue via useState, and
when it differs from the current value, sync state during render
instead of in an effect.

That pattern has a real gap the original effects didn't: useEffect
runs on mount regardless of dependencies, but `useState(value)` for
the tracked prevValue captures the *current* value immediately, so on
mount `value === prevValue` already and the sync block never fires.
Any of these components that can mount with data already available
(query cache hit, or a prop that's simply non-null from the start)
silently kept its hardcoded-empty initial state forever — until the
underlying value later *changed* to something else.

Confirmed regression: node details panel's form (name/color/icon/...)
stayed empty on the first node selected after mount, only populating
once you clicked a second, different node. Same shape, same fix
(derive the initial useState from the current value via a lazy
initializer instead of a hardcoded default) applied to every sibling
with the same bug shape: sketch settings form, analysis title, user
profile form, and the custom-type editor (which also never called its
add-first-field fallback for a brand new type, for the same reason).

Audited every other adjust-during-render conversion from that branch;
the rest already seeded their initial state directly from the current
prop/value (e.g. useState(value) instead of useState('')), so they
don't have this gap.
2026-08-25 09:33:37 +02:00
..
2025-10-09 10:23:25 +02:00
2025-10-09 10:23:25 +02:00