Skip to content

Commit

Permalink
Improve code commenting around focus mount behaviour of rich text Lin…
Browse files Browse the repository at this point in the history
…k UI (#54085)

* Reinstate focus trap and focus first element

* Improve commenting to explain the purpose of the mount controlling
  • Loading branch information
getdave authored Sep 5, 2023
1 parent 8e8048e commit 5be7296
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/format-library/src/link/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ function InlineLinkUI( {
// See https://github.com/WordPress/gutenberg/pull/34742.
const forceRemountKey = useLinkInstanceKey( popoverAnchor );

// The focusOnMount prop shouldn't evolve during render of a Popover
// Focus should only be moved into the Popover when the Link is being created or edited.
// When the Link is in "preview" mode focus should remain on the rich text because at
// this point the Link dialog is informational only and thus the user should be able to
// continue editing the rich text.
// Ref used because the focusOnMount prop shouldn't evolve during render of a Popover
// otherwise it causes a render of the content.
const focusOnMount = useRef( addingLink ? 'firstElement' : false );

Expand Down

0 comments on commit 5be7296

Please sign in to comment.