Skip to content

Commit

Permalink
chore: InputFileの削除ボタン用ロジックを調整
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM committed Jan 15, 2025
1 parent 3b0bb47 commit 0528a2a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/smarthr-ui/src/components/InputFile/InputFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ export const InputFile = forwardRef<HTMLInputElement, Props & ElementProps>(
)

const handleDelete = useCallback(
(index: number) => {
(e: React.MouseEvent<HTMLButtonElement>) => {
if (!inputRef.current) {
return
}

const index = parseInt(e.currentTarget.value, 10)
const newFiles = files.filter((_, i) => index !== i)

updateFiles(newFiles)
Expand Down Expand Up @@ -184,7 +185,8 @@ export const InputFile = forwardRef<HTMLInputElement, Props & ElementProps>(
<Button
variant="text"
prefix={<FaTrashCanIcon />}
onClick={() => handleDelete(index)}
value={index}
onClick={handleDelete}
className="smarthr-ui-InputFile-deleteButton"
>
{destroyButtonText}
Expand Down

0 comments on commit 0528a2a

Please sign in to comment.