@@ -7,7 +7,12 @@ import { SEARCH_SHORTCUTS, INPUT_FIELD_SELECTORS } from '../searchConstants';
77 */
88function isInputField ( activeElement ) {
99 if ( ! activeElement ) return false ;
10-
10+
11+ // Check for Kapa AI input by placeholder text (most reliable)
12+ if ( activeElement . placeholder === "Ask me a question about ClickHouse..." ) {
13+ return true ;
14+ }
15+
1116 return INPUT_FIELD_SELECTORS . some ( selector => {
1217 if ( selector . startsWith ( '#' ) || selector . startsWith ( '[' ) ) {
1318 return activeElement . matches ?. ( selector ) || activeElement . closest ?. ( selector ) ;
@@ -48,13 +53,18 @@ function isSearchShortcut(event) {
4853export function handleSearchKeyboardConflict ( event , isAskAIOpen ) {
4954 if ( ! isSearchShortcut ( event ) ) return ;
5055
51- if ( shouldPreventSearchAction ( isAskAIOpen ) ) {
52- // Special case: allow "/" in input fields
53- if ( event . key === SEARCH_SHORTCUTS . SLASH && ! shouldPreventSearchAction ( isAskAIOpen ) ) {
54- event . stopImmediatePropagation ( ) ;
55- } else {
56- event . preventDefault ( ) ;
57- event . stopImmediatePropagation ( ) ;
58- }
56+ // If Ask AI is not open, don't interfere with normal search behavior
57+ if ( ! isAskAIOpen ) return ;
58+
59+ const activeElement = document . activeElement ;
60+
61+ // If we're typing in an input field when AI is open, allow "/" but prevent search modal
62+ if ( event . key === SEARCH_SHORTCUTS . SLASH && isInputField ( activeElement ) ) {
63+ event . stopImmediatePropagation ( ) ;
64+ return ;
5965 }
66+
67+ // Otherwise, when AI is open and not in input field, prevent all search shortcuts
68+ event . preventDefault ( ) ;
69+ event . stopImmediatePropagation ( ) ;
6070}
0 commit comments