TT-7380 fix: auto-save when editing Segment Reference in Mark Verse step#353
Conversation
0cb534e to
76c7296
Compare
| setData(newData); | ||
| setSegments(); | ||
| toolChanged(verseToolId); | ||
| if (!isChanged(verseToolId)) { |
There was a problem hiding this comment.
toolChanged handles checking if any change is needed, so this is unnecessary code
| } | ||
| if (!init && !isChanged(verseToolId)) toolChanged(verseToolId); | ||
| if (!init) { | ||
| if (!isChanged(verseToolId)) { |
There was a problem hiding this comment.
toolChanged handles checking if any change is needed, so this is unnecessary code
Convert the autosave logic in PassageDetailMarkVerses from a useEffect (triggered by toolsChanged state) to a direct function call invoked on every cell/segment change. This ensures autosave fires immediately when the user edits a Segment Reference cell rather than waiting for a separate state update cycle. Also fix SnackBar open-state detection to use Fragment type-check instead of brittle 'span' type comparison. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
76c7296 to
69df630
Compare
|
|
||
| // Simulate a user boundary edit (init=false) so checkBlockersAndScheduleAutosave | ||
| // runs with "9:9" still in the table — the blocker should be detected and warned. | ||
| act(() => { |
There was a problem hiding this comment.
Copilot claims this test had previously been passing only by accident
| useEffect(() => { | ||
| if ((message?.type === 'span') !== open) { | ||
| setOpen(!open); | ||
| const hasMessage = !!message && message.type !== Fragment; |
There was a problem hiding this comment.
I'm a little nervous about this change because the SnackBar is used in so many different places. But it definitely seems like a bug that previously toasts weren't appearing because their messages were wrapped in non-spans
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [toolsChanged, scheduleAutosave]); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Devin flagged that we are now further diverging from the mobile version, which still uses an effect for this. But the logic is already different enough in the mobile version that I was thinking this is fine
Summary
Converts autosave logic in
PassageDetailMarkVersesfrom auseEffect(triggered bytoolsChangedstate) to a directcheckBlockersAndScheduleAutosave()function called on every cell/segment change — this ensures autosave fires immediately when a user edits a Segment Reference cell rather than waiting for a separate state update cycle.Fixes
SnackBaropen-state detection: replaces the brittlemessage?.type === 'span'check with!!message && message.type !== Fragmentso snackbar correctly opens/closes when message content is a non-span React element.🤖 Generated with Claude Code