Skip to content

Commit ac073a5

Browse files
noisysocksclaude
andauthored
Fix WebKit blur event bug in omnibar components (#1851)
Replace onBlur with onBlurCapture in SearchForm and AiChatForm to fix WebKit-specific bug where blur events don't fire when focus moves to the address bar. The capture phase ensures blur handlers execute in all cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 3b04221 commit ac073a5

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

special-pages/pages/new-tab/app/omnibar/components/AiChatForm.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ export function AiChatForm({ chat, autoFocus, onFocus, onBlur, onInput, onChange
9797
aria-label={t('omnibar_aiChatFormPlaceholder')}
9898
autoComplete="off"
9999
rows={1}
100-
onFocus={onFocus}
101-
onBlur={onBlur}
100+
// Using capture to work around WebKit which doesn't fire focus/blur event when user moves focus from/to address bar.
101+
onFocusCapture={onFocus}
102+
onBlurCapture={onBlur}
102103
onInput={onInput}
103104
onKeyDown={handleKeyDown}
104105
onChange={handleChange}

special-pages/pages/new-tab/app/omnibar/components/SearchForm.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ export function SearchForm({ term, autoFocus, onChangeTerm, onOpenSuggestion, on
6666
};
6767

6868
return (
69-
<form class={styles.form} onBlur={handleBlur} onSubmit={handleSubmit}>
69+
<form
70+
class={styles.form}
71+
// Using onBlurCapture to work around WebKit which doesn't fire blur event when user selects address bar.
72+
onBlurCapture={handleBlur}
73+
onSubmit={handleSubmit}
74+
>
7075
<div class={styles.inputContainer} style={{ '--suffix-text-width': `${measureText(inputSuffixText)}px` }}>
7176
{inputSuffix?.kind === 'visit' ? <GlobeIcon inert /> : <SearchIcon inert />}
7277
<input

0 commit comments

Comments
 (0)