Skip to content

Commit 976e51c

Browse files
committed
📝🤔Todo
1 parent d5ebbcc commit 976e51c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

‎Todo/public/app.js‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ul.id = "todoList"
2222

2323

2424
todoHandler.addEventListener('click', async () => {
25-
let inputVal = todoInput.value.trim()
25+
let inputVal = todoInput.value
2626
if (!inputVal) {
2727
alert("field is empty")
2828
return;
@@ -79,15 +79,18 @@ ul.addEventListener('click', async (e) => {
7979
input.style.border = ""
8080
input.nextElementSibling.innerText = "Edit"
8181
}
82+
8283
let newVal = input.value
8384
let id = input.id
84-
try {
85-
await updateDoc(doc(db, "Todo", id), {
86-
todo: newVal
87-
})
88-
} catch (error) {
89-
console.log("The Error is in UpdateDoc", error);
85+
if (newVal) {
86+
try {
87+
await updateDoc(doc(db, "Todo", id), {
88+
todo: newVal
89+
})
90+
} catch (error) {
91+
console.log("The Error is in UpdateDoc", error);
9092

93+
}
9194
}
9295
}
9396

0 commit comments

Comments
 (0)