Skip to content

Commit

Permalink
chore(otp-input): call onInputBlur after disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermerodz committed Feb 17, 2024
1 parent 6571022 commit 30b5e5e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ export const OTPInput = React.forwardRef<HTMLDivElement, OTPInputProps>(
}
}, [value, onComplete])

React.useEffect(() => {
if (disabled) {
onInputBlur()
}
}, [disabled])

const [selectionMirror, setSelectionMirror] = React.useState<
[number | null, number | null]
>([null, null])
Expand Down Expand Up @@ -449,7 +455,7 @@ export const OTPInput = React.forwardRef<HTMLDivElement, OTPInputProps>(
return render({
slots: Array.from({ length: maxLength }).map((_, slotIdx) => ({
char: value[slotIdx] !== undefined ? value[slotIdx] : null,
isActive: isCurrent(slotIdx) || isSelected(slotIdx),
isActive: isFocused && (isCurrent(slotIdx) || isSelected(slotIdx)),
})),
isFocused,
isHovering,
Expand Down

0 comments on commit 30b5e5e

Please sign in to comment.