@@ -14,12 +14,12 @@ import { TableDataType, RowDataType, TableColumn } from "cdm/FolderModel";
1414import { DatabaseView } from "DatabaseView" ;
1515import StateManager from "StateManager" ;
1616import { getNormalizedPath } from "helpers/VaultManagement" ;
17- import { ActionTypes , DatabaseCore } from "helpers/Constants" ;
17+ import { ActionTypes , DatabaseCore , MetadataColumns } from "helpers/Constants" ;
1818import PlusIcon from "components/img/Plus" ;
1919import { LOGGER } from "services/Logger" ;
2020import DefaultCell from "components/Cell" ;
2121import Header from "components/Header" ;
22- import { c } from "helpers/StylesHelper" ;
22+ import { c , getTotalWidth } from "helpers/StylesHelper" ;
2323import { HeaderNavBar } from "components/NavBar" ;
2424import { getColumnsWidthStyle } from "components/styles/ColumnWidthStyle" ;
2525import { HeaderContext } from "components/contexts/HeaderContext" ;
@@ -196,6 +196,21 @@ export function Table(initialState: TableDataType) {
196196 // Manage input of new row
197197 const [ inputNewRow , setInputNewRow ] = React . useState ( "" ) ;
198198 const newRowRef = React . useRef ( null ) ;
199+ function handleKeyDown ( e : any ) {
200+ if ( e . key === "Enter" ) {
201+ handleAddNewRow ( ) ;
202+ }
203+ }
204+
205+ function handleAddNewRow ( ) {
206+ dataDispatch ( {
207+ type : ActionTypes . ADD_ROW ,
208+ filename : inputNewRow ,
209+ } ) ;
210+ setInputNewRow ( "" ) ;
211+ newRowRef . current . value = "" ;
212+ }
213+
199214 // Manage NavBar
200215 const csvButtonProps = {
201216 columns : columns ,
@@ -215,7 +230,7 @@ export function Table(initialState: TableDataType) {
215230 { ...getTableProps ( {
216231 style : {
217232 ...getTableProps ( ) . style ,
218- width : totalColumnsWidth ,
233+ minWidth : totalColumnsWidth ,
219234 } ,
220235 } ) }
221236 className = { `${ c ( "table noselect" ) } ` }
@@ -234,7 +249,7 @@ export function Table(initialState: TableDataType) {
234249 csvButtonProps = { csvButtonProps }
235250 globalFilterRows = { globalFilterRows }
236251 headerGroupProps = { headerGroups [ 0 ] . getHeaderGroupProps ( {
237- style : { width : totalColumnsWidth } ,
252+ style : { width : getTotalWidth ( columnsWidthState ) } ,
238253 } ) }
239254 />
240255 { /** Headers */ }
@@ -280,6 +295,11 @@ export function Table(initialState: TableDataType) {
280295 { ...headerGroup . getHeaderGroupProps ( {
281296 style : {
282297 ...getDndListStyle ( snapshot . isDraggingOver ) ,
298+ width :
299+ getTotalWidth ( columnsWidthState ) -
300+ columnsWidthState . widthRecord [
301+ MetadataColumns . ADD_COLUMN
302+ ] ,
283303 } ,
284304 } ) }
285305 ref = { provided . innerRef }
@@ -291,6 +311,9 @@ export function Table(initialState: TableDataType) {
291311 draggableId = { `${ column . id } ` }
292312 index = { index }
293313 isDragDisabled = { ( column as any ) . skipPersist }
314+ disableInteractiveElementBlocking = {
315+ ( column as any ) . skipPersist
316+ }
294317 >
295318 { ( provided , snapshot ) => {
296319 const tableCellBaseProps = {
@@ -342,7 +365,7 @@ export function Table(initialState: TableDataType) {
342365 < div
343366 { ...row . getRowProps ( {
344367 style : {
345- maxWidth : `${ totalColumnsWidth } px` ,
368+ minWidth : `${ totalColumnsWidth } px` ,
346369 } ,
347370 } ) }
348371 className = { `${ c ( "tr" ) } ` }
@@ -372,20 +395,11 @@ export function Table(initialState: TableDataType) {
372395 onChange = { ( e ) => {
373396 setInputNewRow ( e . target . value ) ;
374397 } }
398+ onKeyDown = { handleKeyDown }
375399 placeholder = "filename of new row"
376400 />
377401 </ div >
378- < div
379- className = { `${ c ( "td" ) } ` }
380- onClick = { ( ) => {
381- dataDispatch ( {
382- type : ActionTypes . ADD_ROW ,
383- filename : inputNewRow ,
384- } ) ;
385- setInputNewRow ( "" ) ;
386- newRowRef . current . value = "" ;
387- } }
388- >
402+ < div className = { `${ c ( "td" ) } ` } onClick = { handleAddNewRow } >
389403 < span className = "svg-icon svg-gray" style = { { marginRight : 4 } } >
390404 < PlusIcon />
391405 </ span >
0 commit comments