diff --git a/app/ui/features/training/state.js b/app/ui/features/training/state.js index e6d5a625..a6f50ae1 100644 --- a/app/ui/features/training/state.js +++ b/app/ui/features/training/state.js @@ -33,10 +33,11 @@ export function makeSession(api) { if (!queued) return; const { name, doc } = queued; queued = null; + const was = s.error; s.saving = true; try { await api.trainSaveSet(name, doc); s.error = ""; } catch (err) { s.error = `Could not save the set: ${err.message}`; } s.saving = false; - emit(); + if (s.error !== was) emit(); // a saved edit changes nothing on screen; redrawing would take the cursor out of the box being typed in } s.flush = async () => { clearTimeout(timer); timer = null; await push(); }; /** Change the open set in place and save it soon. Does not redraw: the controls on screen already show the edit. */ diff --git a/app/ui/features/training/training.test.js b/app/ui/features/training/training.test.js index 95011c3c..6650adb0 100644 --- a/app/ui/features/training/training.test.js +++ b/app/ui/features/training/training.test.js @@ -104,6 +104,7 @@ test("Tags step: a text box per item under its picture; typing saves the set and await wait(700); const saved = f.calls.filter((c) => c[0] === "save").pop(); assert.equal(saved[2].items[0].caption, "A cat\nsits, calmly"); + assert.ok(box.isConnected && document.querySelector(".cx-captioned textarea") === box, "saving does not redraw the step: the box being typed in stays"); off(); });