Commit 9813724 1 parent a241134 commit 9813724 Copy full SHA for 9813724
File tree 1 file changed +11
-1
lines changed
packages/format-library/src/link
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -212,7 +212,17 @@ function InlineLinkUI( {
212
212
// This caches the last truthy value of the selection anchor reference.
213
213
// This ensures the Popover is positioned correctly on initial submission of the link.
214
214
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
+ }
216
226
217
227
async function handleCreate ( pageTitle ) {
218
228
const page = await createPageEntity ( {
You can’t perform that action at this time.
0 commit comments