Only focus the URL input when no URL has been entered (#15673)

GitOrigin-RevId: e89406f5f0921898901c3c0d298e48e345a65621
This commit is contained in:
Alf Eaton 2023-11-09 11:23:39 +00:00 committed by Copybot
parent b0effa7e4a
commit 1819f3e4e7

View file

@ -41,9 +41,13 @@ export const HrefTooltipContent: FC = () => {
{ signal: controller.signal }
)
// focus the input element if there is content selected in the doc when the tooltip opens
if (!view.state.selection.main.empty) {
inputRef.current.focus()
// focus the URL input element when the tooltip opens, if the view is focused,
// there is content selected in the doc, and no URL has been entered
if (view.hasFocus && !view.state.selection.main.empty) {
const currentUrl = readUrl(view.state)
if (!currentUrl) {
inputRef.current.focus()
}
}
inputRef.current?.addEventListener(