JedWatson / JedWatson/react-select
`ref.blur()` leaves broken state if invoked on `onFocus` in `<Creatable />`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
Description
There is a onFocus handler in a <Creatable/> component, inside of it we invoke ref.blur().
It blurs the component, but also leaves it in a broken state. The focus ring is still on, and the component is uneditable
const stateMachine = useRef()
return (
<Creatable
ref={stateMachine}
onFocus={() => stateMachine.current.blur()}
/>
)
Reproduction: https://codesandbox.io/s/actual-creatable-6pq682
We "fixed" it by delaying the blur
const stateMachine = useRef()
return (
<Creatable
ref={stateMachine}
onFocus={() => setTimeout(() => stateMachine.current.blur(), 500)}
/>
)
Reproduction: https://codesandbox.io/s/expected-creatable-8m869m
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided actual-creatable CodeSandbox and trace the focus path when its ref.blur() method is called from onFocus. Compare it with the delayed-blur reproduction; done means immediate blur leaves the component editable and removes the focus ring without requiring a timeout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100