Skip to content

Commit b6ad130

Browse files
committed
Prevent focusing input when warning is present
- use axios instead of fetch
1 parent ad6a9cc commit b6ad130

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
302302
raw_text: props.value,
303303
context_file_paths: props.selected_files ?? []
304304
})
305-
input_ref.current.focus()
305+
if (!props.warning) {
306+
input_ref.current.focus()
307+
}
306308
set_caret_position_for_div(input_ref.current, display_pos)
307309
} else if (is_focused) {
308310
set_caret_position_for_div(input_ref.current, selection_start)
@@ -375,7 +377,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
375377
[styles['container__inner--selecting']]: is_text_selecting
376378
})}
377379
onKeyDown={handle_container_key_down}
378-
onClick={() => input_ref.current?.focus()}
380+
onClick={() => !props.warning && input_ref.current?.focus()}
379381
>
380382
<div className={styles['input-wrapper']}>
381383
{props.tabs_count > 1 ? (
@@ -496,7 +498,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
496498
<div
497499
className={styles.footer}
498500
onClick={() => {
499-
if (input_ref.current) {
501+
if (input_ref.current && !props.warning) {
500502
input_ref.current.focus()
501503
const selection = window.getSelection()
502504
if (selection) {

‎packages/ui/src/components/editor/panel/prompts/PromptField/hooks/use-handlers/use-handlers.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const use_handlers = (
157157
useEffect(() => {
158158
if (params.input_ref.current && !props_ref.current.warning) {
159159
requestAnimationFrame(() => {
160-
if (!params.input_ref.current) return
160+
if (!params.input_ref.current || props_ref.current.warning) return
161161
params.input_ref.current.focus({ preventScroll: true })
162162
})
163163
}
@@ -166,7 +166,7 @@ export const use_handlers = (
166166
useEffect(() => {
167167
if (params.input_ref.current && !props_ref.current.warning) {
168168
requestAnimationFrame(() => {
169-
if (!params.input_ref.current) return
169+
if (!params.input_ref.current || props_ref.current.warning) return
170170
params.input_ref.current.focus({ preventScroll: true })
171171
const selection = window.getSelection()
172172
if (selection) {

0 commit comments

Comments
 (0)