@@ -155,12 +155,14 @@ export function HeaderText({val, level='body-sm', sx, ...rest}) {
155155}
156156
157157const blurEnter = [ 'blur' , 'enter' ] ;
158+ const syntaxTipProps = { enterDelay : 300 } ; // filter boxes and constraint cells can open their syntax tooltip quickly
158159
159160function Filter ( { cname, onFilter, filterInfo, tbl_id} ) {
160161
161162 const colGetter = ( ) => getColumn ( getTblById ( ( tbl_id ) ) , cname ) ?? { } ;
162163 const col = useStoreConnector ( colGetter ) ;
163164 const [ showTooltip , setShowTooltip ] = useState ( true ) ;
165+ const [ editing , setEditing ] = useState ( false ) ; // the syntax tooltip shows only while this box has focus
164166 const dropdownEl = useRef ( null ) ;
165167
166168 useEffect ( ( ) => {
@@ -191,13 +193,19 @@ function Filter({cname, onFilter, filterInfo, tbl_id}) {
191193 validator = { validator }
192194 fieldKey = { name }
193195 sx = { { width : 1 , '--Input-radius' : '' } }
194- tooltip = { showTooltip && FILTER_CONDITION_TTIPS }
196+ tooltip = { editing && showTooltip && FILTER_CONDITION_TTIPS }
195197 value = { filterInfoCls . getFilter ( name ) }
196198 onChange = { onFilter }
197199 actOn = { blurEnter }
198200 showWarning = { false }
199201 slotProps = { {
200- input : { size :'sm' , endDecorator }
202+ input : { size :'sm' , endDecorator, autoComplete : 'off' } ,
203+ // Handle focus on the dropdown or checkboxes bubbling up and triggering the tooltip
204+ control : {
205+ onFocus : ( e ) => setEditing ( e . target . tagName === 'INPUT' && e . currentTarget . contains ( e . target ) ) ,
206+ onBlur : ( ) => setEditing ( false ) ,
207+ } ,
208+ tooltip : syntaxTipProps ,
201209 } }
202210 />
203211 ) ;
@@ -530,8 +538,14 @@ export const createInputCell = (tooltips, size = 10, validator, onChange, style)
530538 onChange && onChange ( v , data , rowIndex , colIdx ) ;
531539 } ;
532540
533- return ( { rowIndex, data, colIdx} ) => {
534- const val = get ( data , [ rowIndex , colIdx ] ) ;
541+ return function InputCell ( { rowIndex, data, colIdx} ) {
542+ const [ editing , setEditing ] = useState ( false ) ; // the syntax tooltip shows only while this box has focus
543+ const [ shownRow , setShownRow ] = useState ( rowIndex ) ;
544+ if ( shownRow !== rowIndex ) { // clear editing when a scroll moves the cell to another row
545+ setShownRow ( rowIndex ) ;
546+ setEditing ( false ) ;
547+ }
548+ const val = data ?. [ rowIndex ] ?. [ colIdx ] ;
535549
536550
537551 if ( val === NOT_CELL_DATA ) {
@@ -543,13 +557,14 @@ export const createInputCell = (tooltips, size = 10, validator, onChange, style)
543557 key = { rowIndex + '-' + colIdx }
544558 validator = { ( v ) => validator ( v , data , rowIndex , colIdx ) }
545559 sx = { { '.MuiInput-root' :{ 'minHeight' :'3px' , 'borderRadius' :4 } } }
546- tooltip = { tooltips }
560+ tooltip = { editing && tooltips }
547561 size = { size }
548562 style = { style }
549563 value = { val }
550564 onChange = { ( v ) => changeHandler ( rowIndex , data , colIdx , v ) }
551565 actOn = { [ 'blur' , 'enter' ] }
552566 showWarning = { false }
567+ slotProps = { { input : { autoComplete : 'off' } , control : { onFocus : ( ) => setEditing ( true ) , onBlur : ( ) => setEditing ( false ) } , tooltip : syntaxTipProps } }
553568 />
554569 </ Box >
555570 ) ;
@@ -571,7 +586,13 @@ export const createInputCell = (tooltips, size = 10, validator, onChange, style)
571586 */
572587export const inputColumnRenderer = ( { tbl_id, cname, tooltips, style= { } , isReadOnly, validator, onChange, ...props } ) => {
573588
574- return ( { rowIndex, data, colIdx} ) => {
589+ return function InputColumnCell ( { rowIndex, data, colIdx} ) {
590+ const [ editing , setEditing ] = useState ( false ) ; // the tooltip shows only while this box has focus
591+ const [ shownRow , setShownRow ] = useState ( rowIndex ) ;
592+ if ( shownRow !== rowIndex ) { // clear editing when a scroll moves the cell to another row
593+ setShownRow ( rowIndex ) ;
594+ setEditing ( false ) ;
595+ }
575596 const val = get ( data , [ rowIndex , colIdx ] ) ;
576597 if ( isReadOnly && isReadOnly ( rowIndex , data , colIdx ) ) {
577598 return < div style = { { width : '100%' , height : '100%' , ...style } } > { val } </ div > ;
@@ -582,11 +603,12 @@ export const inputColumnRenderer = ({tbl_id, cname, tooltips, style={}, isReadOn
582603 key = { rowIndex + '-' + colIdx }
583604 sx = { { '.MuiInput-root' :{ 'minHeight' :'3px' , 'borderRadius' :4 } } }
584605 validator = { validator && ( ( v ) => validator ( v , data , rowIndex , colIdx ) ) }
585- tooltip = { tooltips }
606+ tooltip = { editing && tooltips }
586607 style = { { width : '100%' , boxSizing : 'border-box' , ...style } }
587608 value = { val }
588609 onChange = { makeChangeHandler ( rowIndex , data , colIdx , tbl_id , cname , validator , onChange ) }
589610 actOn = { [ 'blur' , 'enter' ] }
611+ slotProps = { { input : { autoComplete : 'off' } , control : { onFocus : ( ) => setEditing ( true ) , onBlur : ( ) => setEditing ( false ) } , tooltip : syntaxTipProps } }
590612 />
591613 </ Box >
592614 ) ;
0 commit comments