@@ -105,6 +105,45 @@ export const ChatInputBar = ({
105105 const { submitAnswers } = useAskUserBridge ( )
106106 const [ askUserTitle , setAskUserTitle ] = React . useState ( ' Action Required ' )
107107
108+ // Shared key intercept handler for suggestion menu navigation
109+ const handleKeyIntercept = useEvent (
110+ ( key : {
111+ name ?: string
112+ shift ?: boolean
113+ ctrl ?: boolean
114+ meta ?: boolean
115+ option ?: boolean
116+ } ) => {
117+ // Intercept navigation keys when suggestion menu is active
118+ // The useChatKeyboard hook will handle menu selection/navigation
119+ const hasSuggestions = hasSlashSuggestions || hasMentionSuggestions
120+ if ( ! hasSuggestions ) return false
121+
122+ const isPlainEnter =
123+ ( key . name === 'return' || key . name === 'enter' ) &&
124+ ! key . shift &&
125+ ! key . ctrl &&
126+ ! key . meta &&
127+ ! key . option
128+ const isTab = key . name === 'tab' && ! key . ctrl && ! key . meta && ! key . option
129+ const isUpDown =
130+ ( key . name === 'up' || key . name === 'down' ) &&
131+ ! key . ctrl &&
132+ ! key . meta &&
133+ ! key . option
134+
135+ // Don't intercept Up/Down when user is navigating history
136+ if ( isUpDown && lastEditDueToNav ) {
137+ return false
138+ }
139+
140+ if ( isPlainEnter || isTab || isUpDown ) {
141+ return true
142+ }
143+ return false
144+ } ,
145+ )
146+
108147 if ( feedbackMode ) {
109148 return (
110149 < FeedbackContainer
@@ -200,45 +239,6 @@ export const ChatInputBar = ({
200239 inputMode === 'default' ? inputPlaceholder : modeConfig . placeholder
201240 const borderColor = theme [ modeConfig . color ]
202241
203- // Shared key intercept handler for suggestion menu navigation
204- const handleKeyIntercept = useEvent (
205- ( key : {
206- name ?: string
207- shift ?: boolean
208- ctrl ?: boolean
209- meta ?: boolean
210- option ?: boolean
211- } ) => {
212- // Intercept navigation keys when suggestion menu is active
213- // The useChatKeyboard hook will handle menu selection/navigation
214- const hasSuggestions = hasSlashSuggestions || hasMentionSuggestions
215- if ( ! hasSuggestions ) return false
216-
217- const isPlainEnter =
218- ( key . name === 'return' || key . name === 'enter' ) &&
219- ! key . shift &&
220- ! key . ctrl &&
221- ! key . meta &&
222- ! key . option
223- const isTab = key . name === 'tab' && ! key . ctrl && ! key . meta && ! key . option
224- const isUpDown =
225- ( key . name === 'up' || key . name === 'down' ) &&
226- ! key . ctrl &&
227- ! key . meta &&
228- ! key . option
229-
230- // Don't intercept Up/Down when user is navigating history
231- if ( isUpDown && lastEditDueToNav ) {
232- return false
233- }
234-
235- if ( isPlainEnter || isTab || isUpDown ) {
236- return true
237- }
238- return false
239- } ,
240- )
241-
242242 if ( askUserState ) {
243243 return (
244244 < box
0 commit comments