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

Link Control: Unable to edit text in development mode #62089

Closed
Mamaduka opened this issue May 29, 2024 · 1 comment · Fixed by #62141
Closed

Link Control: Unable to edit text in development mode #62089

Mamaduka opened this issue May 29, 2024 · 1 comment · Fixed by #62141
Assignees
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@Mamaduka
Copy link
Member

The LinkControl popover steals the focus and prevents editing the text in development mode. See: #61943.

Affected e2e tests:

  • editor/blocks/links.spec.js - should allow editing text underneath popover when activated via mouse.
  • editor/various/block-bindings.spec.js - should add empty button block when pressing enter.

Steps to reproduce

  • Checkout branch from Try: Re-enable React StrictMode #61943.
  • Enable SCRIPT_DEBUG for non wp-env setups.
  • Create a post.
  • Add a paragraph and add a link to some selection.
  • Try editing the linked text.

Screencast

CleanShot.2024-05-29.at.12.56.40.mp4
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels May 29, 2024
@Mamaduka
Copy link
Member Author

My guess is that the following effect might be responsible for the bug:

useEffect( () => {
// We don't auto focus into the Link UI on mount
// because otherwise using the keyboard to select text
// *within* the link format is not possible.
if ( isMounting.current ) {
isMounting.current = false;
return;
}
// Scenario - when:
// - switching between editable and non editable LinkControl
// - clicking on a link
// ...then move focus to the *first* element to avoid focus loss
// and to ensure focus is *within* the Link UI.
const nextFocusTarget =
focus.focusable.find( wrapperNode.current )[ 0 ] ||
wrapperNode.current;
nextFocusTarget.focus();
isEndingEditWithFocus.current = false;
}, [ isEditingLink, isCreatingPage ] );

cc @getdave, @jeryj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant