Skip to content

Commit

Permalink
fix: item selections
Browse files Browse the repository at this point in the history
The selected item shouldn't be selected when the dir changes.
  • Loading branch information
Mersho committed Sep 25, 2024
1 parent f7ee7f1 commit fb973ea
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions FileBox/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ function Item({ name, onCheckChange, modifiedDate, icon, size, onDoubleClick }:
const [isChecked, setIsChecked] = useState(false)

function handleChange(checked?: boolean) {
setIsChecked(checked ?? !isChecked)
onCheckChange(checked ?? !isChecked)
const newCheckedState = checked ?? !isChecked
setIsChecked(newCheckedState)
onCheckChange(newCheckedState)
}

useEffect(() => {
setIsChecked(false)
}, [name])

return (
<div
className="relative w-32 lg:w-40 p-4 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 dark:bg-gray-700"
Expand Down

0 comments on commit fb973ea

Please sign in to comment.