Skip to content

Commit

Permalink
fix bug with delete list not resetting input focus
Browse files Browse the repository at this point in the history
  • Loading branch information
avidrucker committed Nov 8, 2023
1 parent 691b681 commit 0eb114b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ function App() {
// eslint-disable-next-line
}, [isPrioritizing])

// focusing on the input after deleting the list
useEffect(() => {
if (!showingDeleteModal && tasks.length === 0) {
inputRef.current.focus();
}
}, [showingDeleteModal, tasks.length]);

const saveTasksToLocal = (tasks) => {
saveToLocalStorage('tasks', tasks);
};
Expand Down Expand Up @@ -194,9 +201,6 @@ function App() {
handleListChange(updatedTasks);
setErrMsg("");
setShowingDeleteModal(false);
if (inputRef.current) {
inputRef.current.focus();
}
};

const handleNoUI = () => {
Expand Down

0 comments on commit 0eb114b

Please sign in to comment.