fix: move empty text logic to state, fix tests

This commit is contained in:
2026-02-08 21:33:15 +05:00
parent 59745eac4f
commit a146fee41c
4 changed files with 23 additions and 88 deletions
+1 -4
View File
@@ -10,10 +10,7 @@
let text: string = $state("");
function addText() {
let trimmed = text.trim();
if (trimmed.length !== 0) {
textsState.addText(trimmed);
}
textsState.addText(text);
text = "";
}
+1
View File
@@ -14,6 +14,7 @@ function createState() {
return texts;
},
addText(text: string) {
if (text.trim().length === 0) return;
texts.push({ text, id: nextId });
nextId++;
},