Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix focus loss on unsync and edit from navigation link inspector
The unsync and edit button enables the disabled input and removes the button that was focused. This causes a focus loss.

I added:
- Ref for the input
- Ref for knowing if we should focus on next render (we can't focus immediately, as the input is disabled and cannot receive focus)
- useEffect to check if we should send focus to the input when hasUrlBinding changes
  • Loading branch information
jeryj committed Oct 20, 2025
commit 167d31691f327e58bd2718159e086854ce4b2a5a
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export function Controls( { attributes, setAttributes, clientId } ) {
};

useEffect( () => {
// Checking for ! hasUrlBinding is a defensive check, as we would
// only want to focus the input if the url is not bound to an entity.
if ( ! hasUrlBinding && shouldFocusURLInputRef.current ) {
urlInputRef.current?.focus();
}
Expand Down