File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
packages/compass-query-bar/src/components Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -91,11 +91,20 @@ function createAIPlaceholderHTMLPlaceholder({
9191 containerEl . appendChild ( placeholderTextEl ) ;
9292
9393 const aiButtonEl = document . createElement ( 'button' ) ;
94- aiButtonEl . onclick = ( e ) => {
94+ // By default placeholder container will have pointer events disabled
95+ aiButtonEl . style . pointerEvents = 'auto' ;
96+ // We stop mousedown from propagating and preventing default behavior to avoid
97+ // input getting focused on placeholder click (that's the event that
98+ // codemirror uses internally to set focus to the input)
99+ aiButtonEl . addEventListener ( 'mousedown' , ( e ) => {
100+ e . preventDefault ( ) ;
101+ e . stopPropagation ( ) ;
102+ } ) ;
103+ aiButtonEl . addEventListener ( 'click' , ( e ) => {
95104 e . preventDefault ( ) ;
96105 e . stopPropagation ( ) ;
97106 onClickAI ( ) ;
98- } ;
107+ } ) ;
99108
100109 aiButtonEl . className = cx (
101110 aiQueryEntryStyles ,
Original file line number Diff line number Diff line change @@ -75,11 +75,6 @@ const moreOptionsContainerStyles = css({
7575const filterContainerStyles = css ( {
7676 position : 'relative' ,
7777 flexGrow : 1 ,
78-
79- // Override codemirror styles to make the `Ask AI` button clickable.
80- '& .cm-placeholder' : {
81- pointerEvents : 'auto !important' as any , // Cast to any as !important errors ts.
82- } ,
8378} ) ;
8479
8580const filterLabelStyles = css ( {
You can’t perform that action at this time.
0 commit comments