Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom Out: Focus search when showing an insertion point #63867

Closed
scruffian opened this issue Jul 23, 2024 · 3 comments · Fixed by #64396
Closed

Zoom Out: Focus search when showing an insertion point #63867

scruffian opened this issue Jul 23, 2024 · 3 comments · Fixed by #64396
Assignees
Labels
[Feature] Zoom Out [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@scruffian
Copy link
Contributor

What problem does this address?

In zoom out, when you click on the inserter button [+] the insertion marker shows, but it's not clear to users what is happening.

What is your proposed solution?

When the inserter button is clicked we should focus the search input so users can see where their next action should be.

@getdave
Copy link
Contributor

getdave commented Aug 9, 2024

I've looked into this a bit. The search component is here

<SearchControl
__nextHasNoMarginBottom
className="block-editor-inserter__search"
onChange={ ( value ) => {
if ( hoveredItem ) {
setHoveredItem( null );
}
setFilterValue( value );
} }
value={ filterValue }
label={ __( 'Search for blocks and patterns' ) }
placeholder={ __( 'Search' ) }
/>

It is possible to wrap this in a <div> and use the useFocusOnMount hook to programmatically focus the search. This can be done conditionally by passing the ref returned from useFocusOnMount or just passing null.

The problem is how to do this conditionally? It will require some new global state to track whether or not to focus the search.

We already have setIsInserterOpened, but that is Boolean. We could add options to that action to allow consumers to control a separate focus state.

@scruffian
Copy link
Contributor Author

I believe setIsInserterOpened uses setInserterIsOpened which takes whole load of options:

@getdave
Copy link
Contributor

getdave commented Aug 9, 2024

Thanks. Funnily enough I just found that bit. I'm manipulating it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Zoom Out [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants