Просмотр исходного кода

guard destroyed input field in timeout

Sebastian Herrlinger 3 недель назад
Родитель
Сommit
58ba486375
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx

+ 5 - 1
packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx

@@ -241,7 +241,11 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
             focusedTextColor={theme.textMuted}
             ref={(r) => {
               input = r
-              setTimeout(() => input.focus(), 1)
+              setTimeout(() => {
+                if (!input) return
+                if (input.isDestroyed) return
+                input.focus()
+              }, 1)
             }}
             placeholder={props.placeholder ?? "Search"}
           />