Explorar o código

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

GitOrigin-RevId: e89406f5f0921898901c3c0d298e48e345a65621
Alf Eaton %!s(int64=2) %!d(string=hai) anos
pai
achega
1819f3e4e7

+ 7 - 3
services/web/frontend/js/features/source-editor/components/command-tooltip/href-tooltip.tsx

@@ -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(