@@ -551,17 +551,26 @@ const TableRow = (props: { selected: boolean, readonly selectedColumn: string |
551551 { tableInfo . filter ( ( v ) => visibleColumns . includes ( v . name ) ) . map ( ( { name } , i ) => {
552552 const value = props . record [ name ] as remote . SQLite3Value
553553 const input = props . selectedColumn === name ? props . input : undefined
554+ const onMouseDown = async ( ev : MouseEvent ) => {
555+ if ( ev . target instanceof HTMLTextAreaElement ) { return } // in-place input
556+ ev . preventDefault ( )
557+ if ( ev . button === 2 ) { return }
558+ const editorState = useEditorStore . getState ( )
559+ if ( editorState . statement === "UPDATE" && editorState . row === props . row && editorState . column === name ) { return }
560+ if ( tableName === undefined ) { return }
561+ if ( ! await beforeUnmount ( ) ) { return }
562+ update ( tableName , name , props . row )
563+ }
554564 return < td
555565 class = { "pl-[10px] pr-[10px] overflow-hidden border-r-[1px] border-[var(--td-border-color)] border-b-[1px] border-b-[var(--td-border-color)] " + ( tableName !== undefined ? "clickable" : "" ) + " " + ( input ? "editing" : "" ) }
556566 style = { { maxWidth : props . columnWidths [ i ] } }
557- onMouseDown = { async ( ev ) => {
558- if ( ev . target instanceof HTMLTextAreaElement ) { return } // in-place input
567+ onMouseDown = { onMouseDown }
568+ onContextMenu = { ( ev ) => {
569+ if ( input ?. textarea && ! input . textarea . classList . contains ( "single-click" ) ) { return } // if the in-place input is visible
559570 ev . preventDefault ( )
560- const editorState = useEditorStore . getState ( )
561- if ( editorState . statement === "UPDATE" && editorState . row === props . row && editorState . column === name ) { return }
562- if ( tableName === undefined ) { return }
563- if ( ! await beforeUnmount ( ) ) { return }
564- update ( tableName , name , props . row )
571+ renderContext ( ev , < >
572+ < button onClick = { onMouseDown } > Update</ button >
573+ </ > )
565574 } }
566575 data-testid = { `cell ${ props . rowNumber - 1n } , ${ i } ` } >
567576 < pre class = { "overflow-hidden text-ellipsis whitespace-nowrap max-w-[50em] [font-size:inherit] " + ( input ?. textarea && cursorVisibility ? "cursor-line" : "" ) } >
0 commit comments