fix: move empty text logic to state, fix tests
This commit is contained in:
@@ -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 = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ function createState() {
|
||||
return texts;
|
||||
},
|
||||
addText(text: string) {
|
||||
if (text.trim().length === 0) return;
|
||||
texts.push({ text, id: nextId });
|
||||
nextId++;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user