Inserter: search field autoFocus breaks withFocusReturn
#1917
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Type] Bug
An existing feature does not function as intended
The inserter was recently modified to have the search field as first thing in the inserter content and set initial focus on the search field using
autoFocus
.Turns out this breaks the way
withFocusReturn
works. To reproduce:Setting focus on a component when it gets mounted is not compatible with how
withFocusReturn
gets thedocument.activeElement
oncomponentDidMount
. In this case, when the inserter menu gets mounted, thedocument.activeElement
is the search field. Tested in Chrome and Firefox on macOS,this.activeElement
inwithFocusReturn
actually returns the search field.Question: why getting the active element on
componentDidMount
? UsingcomponentWillMount
would probably solve the issue. /cc @aduthThe text was updated successfully, but these errors were encountered: