Skip to content

Commit 9813724

Browse files
authored
Try a fix (#58282)
1 parent a241134 commit 9813724

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/format-library/src/link/inline.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,17 @@ function InlineLinkUI( {
212212
// This caches the last truthy value of the selection anchor reference.
213213
// This ensures the Popover is positioned correctly on initial submission of the link.
214214
const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
215-
popoverAnchor.getBoundingClientRect = () => cachedRect;
215+
216+
// If the link is not active (i.e. it is a new link) then we need to
217+
// override the getBoundingClientRect method on the anchor element
218+
// to return the cached value of the selection represented by the text
219+
// that the user selected to be linked.
220+
// If the link is active (i.e. it is an existing link) then we allow
221+
// the default behaviour of the popover anchor to be used. This will get
222+
// the anchor based on the `<a>` element in the rich text.
223+
if ( ! isActive ) {
224+
popoverAnchor.getBoundingClientRect = () => cachedRect;
225+
}
216226

217227
async function handleCreate( pageTitle ) {
218228
const page = await createPageEntity( {

0 commit comments

Comments
 (0)