Skip to content

Commit

Permalink
chore(input): remove re-focus feature for password manager badges
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermerodz committed Nov 1, 2024
1 parent 208ba3a commit 948354e
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions packages/input-otp/src/use-pwm-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ export function usePasswordManagerBadge({
pushPasswordManagerStrategy: OTPInputProps['pushPasswordManagerStrategy']
isFocused: boolean
}) {
// Metadata for instant updates (not React state)
const pwmMetadata = React.useRef<{
done: boolean
refocused: boolean
}>({
done: false,
refocused: false,
})

/** Password managers have a badge
* and I'll use this state to push them
* outside the input */
Expand Down Expand Up @@ -98,19 +89,6 @@ export function usePasswordManagerBadge({

setHasPWMBadge(true)
setDone(true)

// For specific password managers,
// the input has to be re-focused
// to trigger a re-position of the badge.
if (!pwmMetadata.current.refocused && document.activeElement === input) {
const sel = [input.selectionStart, input.selectionEnd]
input.blur()
input.focus()
// Recover the previous selection
input.setSelectionRange(sel[0], sel[1])

pwmMetadata.current.refocused = true
}
}, [containerRef, inputRef, done, pushPasswordManagerStrategy])

React.useEffect(() => {
Expand Down

0 comments on commit 948354e

Please sign in to comment.