Compare commits

...

3 Commits

Author SHA1 Message Date
Nikhil Sonti
88ea2976e9 fix: use stateReducer to block Shift+Enter in combobox
preventDownshiftDefault on the SyntheticEvent doesn't reliably prevent
downshift from processing Enter. Switch to stateReducer, which is
downshift's official customization mechanism: track shiftKey in a ref
via onKeyDown, then return current state from the reducer when
InputKeyDownEnter fires with Shift held.
2026-03-31 17:44:20 -07:00
Nikhil Sonti
3f8a70e5aa fix: use preventDownshiftDefault instead of preventDefault
preventDefault() doesn't stop downshift's internal Enter key handling.
Downshift checks event.nativeEvent.preventDownshiftDefault to decide
whether to skip its built-in behavior.
2026-03-31 17:17:56 -07:00
Nikhil Sonti
515f90f7a7 fix: prevent Shift+Enter from triggering chat in new tab search input
Shift+Enter in the new tab combobox was being processed by downshift as
a regular Enter key, causing it to start a chat session. Guard the
onKeyDown handler to call preventDefault() when Shift is held, so
downshift skips the event entirely.

Closes #560
2026-03-31 17:10:41 -07:00

View File

@@ -93,6 +93,7 @@ export const NewTab = () => {
const [mounted, setMounted] = useState(false)
const inputRef = useRef<HTMLInputElement>(null)
const tabsDropdownRef = useRef<HTMLDivElement>(null)
const shiftHeldRef = useRef(false)
const [selectedTabs, setSelectedTabs] = useState<chrome.tabs.Tab[]>([])
const [shortcutsDialogOpen, setShortcutsDialogOpen] = useState(false)
const [mentionState, setMentionState] = useState<MentionState>({
@@ -180,6 +181,16 @@ export const NewTab = () => {
} = useCombobox<SuggestionItem>({
items: flatItems,
itemToString: (item) => (item ? getSuggestionLabel(item) : ''),
stateReducer: (state, actionAndChanges) => {
if (
actionAndChanges.type ===
useCombobox.stateChangeTypes.InputKeyDownEnter &&
shiftHeldRef.current
) {
return state
}
return actionAndChanges.changes
},
onSelectedItemChange({ selectedItem }) {
if (selectedItem) {
runSelectedAction(selectedItem)
@@ -492,6 +503,7 @@ export const NewTab = () => {
ref: inputRef,
onChange: (e) => handleInputChange(e.currentTarget.value),
onKeyDown: (e) => {
shiftHeldRef.current = e.shiftKey
if (!mentionStateRef.current.isOpen) return
if (e.key === 'Tab') {
e.preventDefault()