@@ -23,6 +23,7 @@ import { useContextMenuContext } from '../../contexts/ContextMenuContext'
2323import { useRowContext } from '../../contexts/RowContext'
2424import { useTableContext } from '../../contexts/TableContext'
2525import { moveCell } from '../../helpers/cell-navigation'
26+ import { addLineBreak } from '../../helpers/line-break'
2627import { shallowCompare } from '../../helpers/shallow-compare'
2728import { CellType , GenericRowData } from '../../types'
2829
@@ -88,11 +89,13 @@ function TableCell({
8889 */
8990 switch ( e . key ) {
9091 case 'Enter' : {
91- if ( e . shiftKey ) {
92- return
93- }
9492 e . preventDefault ( )
9593 if ( ! isViewMode ) {
94+ // Allow Alt+Enter to add new line
95+ if ( e . altKey ) {
96+ addLineBreak ( e . currentTarget as HTMLTextAreaElement )
97+ return
98+ }
9699 if ( row . id === NEW_ROW_ID || rowIndex === - 1 ) {
97100 if (
98101 ! shallowCompare ( tableMeta ?. tempRowData . current , {
@@ -110,7 +113,7 @@ function TableCell({
110113 row,
111114 rowIndex,
112115 columnIndex,
113- direction : 'down' ,
116+ direction : e . shiftKey ? 'up' : 'down' ,
114117 allowCrossBoundaries : true ,
115118 } )
116119 break
@@ -260,7 +263,6 @@ function TableCell({
260263 } }
261264 ref = { cellContainerRef }
262265 className = { styles . cell }
263- onClick = { startEditing }
264266 onContextMenu = { ! isViewMode ? onContextMenu : undefined }
265267 >
266268 { /* if editing new row, show text area for all cells in the row */ }
@@ -297,6 +299,7 @@ function TableCell({
297299 />
298300 ) : (
299301 < div
302+ onClick = { startEditing }
300303 style = { {
301304 display : 'flex' ,
302305 height : '100%' ,
@@ -307,6 +310,7 @@ function TableCell({
307310 wordBreak : 'break-word' ,
308311 fontSize : '0.875rem' ,
309312 cursor : 'cell' ,
313+
310314 backgroundColor : isHighlightingCell
311315 ? 'var(--chakra-colors-orange-200)'
312316 : hasMatchingSearch
0 commit comments