Skip to content

Commit

Permalink
Try a fix (#58282)
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Jan 26, 2024
1 parent a241134 commit 9813724
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/format-library/src/link/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,17 @@ function InlineLinkUI( {
// This caches the last truthy value of the selection anchor reference.
// This ensures the Popover is positioned correctly on initial submission of the link.
const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
popoverAnchor.getBoundingClientRect = () => cachedRect;

// If the link is not active (i.e. it is a new link) then we need to
// override the getBoundingClientRect method on the anchor element
// to return the cached value of the selection represented by the text
// that the user selected to be linked.
// If the link is active (i.e. it is an existing link) then we allow
// the default behaviour of the popover anchor to be used. This will get
// the anchor based on the `<a>` element in the rich text.
if ( ! isActive ) {
popoverAnchor.getBoundingClientRect = () => cachedRect;
}

async function handleCreate( pageTitle ) {
const page = await createPageEntity( {
Expand Down

0 comments on commit 9813724

Please sign in to comment.