diff --git a/packages/dataviews/src/dataviews-layouts/table/column-header-menu.tsx b/packages/dataviews/src/dataviews-layouts/table/column-header-menu.tsx index 7071e54620f369..05d14d6164b626 100644 --- a/packages/dataviews/src/dataviews-layouts/table/column-header-menu.tsx +++ b/packages/dataviews/src/dataviews-layouts/table/column-header-menu.tsx @@ -102,151 +102,160 @@ const _HeaderMenu = forwardRef( function HeaderMenu< Item >( return ( - { header } - { view.sort && isSorted && ( - - ) } - - } - style={ { minWidth: '240px' } } + // align="start" TODO: align prop doesn't exist on Menu — is it ok to just remove > - - { isSortable && ( - - { SORTING_DIRECTIONS.map( - ( direction: SortDirection ) => { - const isChecked = - view.sort && - isSorted && - view.sort.direction === direction; + + } + > + { header } + { view.sort && isSorted && ( + + ) } + + + + { isSortable && ( + + { SORTING_DIRECTIONS.map( + ( direction: SortDirection ) => { + const isChecked = + view.sort && + isSorted && + view.sort.direction === direction; - const value = `${ fieldId }-${ direction }`; + const value = `${ fieldId }-${ direction }`; - return ( - { - onChangeView( { - ...view, - sort: { - field: fieldId, - direction, - }, - } ); - } } - > - - { sortLabels[ direction ] } - - - ); - } - ) } - - ) } - { canAddFilter && ( + return ( + { + onChangeView( { + ...view, + sort: { + field: fieldId, + direction, + }, + } ); + } } + > + + { sortLabels[ direction ] } + + + ); + } + ) } + + ) } + { canAddFilter && ( + + } + onClick={ () => { + setOpenedFilter( fieldId ); + onChangeView( { + ...view, + page: 1, + filters: [ + ...( view.filters || [] ), + { + field: fieldId, + value: undefined, + operator: operators[ 0 ], + }, + ], + } ); + } } + > + + { __( 'Add filter' ) } + + + + ) } } + prefix={ } + disabled={ index < 1 } onClick={ () => { - setOpenedFilter( fieldId ); onChangeView( { ...view, - page: 1, - filters: [ - ...( view.filters || [] ), - { - field: fieldId, - value: undefined, - operator: operators[ 0 ], - }, + fields: [ + ...( visibleFieldIds.slice( + 0, + index - 1 + ) ?? [] ), + fieldId, + visibleFieldIds[ index - 1 ], + ...visibleFieldIds.slice( index + 1 ), ], } ); } } > - { __( 'Add filter' ) } + { __( 'Move left' ) } - - ) } - - } - disabled={ index < 1 } - onClick={ () => { - onChangeView( { - ...view, - fields: [ - ...( visibleFieldIds.slice( - 0, - index - 1 - ) ?? [] ), - fieldId, - visibleFieldIds[ index - 1 ], - ...visibleFieldIds.slice( index + 1 ), - ], - } ); - } } - > - { __( 'Move left' ) } - - } - disabled={ index >= visibleFieldIds.length - 1 } - onClick={ () => { - onChangeView( { - ...view, - fields: [ - ...( visibleFieldIds.slice( 0, index ) ?? - [] ), - visibleFieldIds[ index + 1 ], - fieldId, - ...visibleFieldIds.slice( index + 2 ), - ], - } ); - } } - > - { __( 'Move right' ) } - - { isHidable && field && ( } + prefix={ } + disabled={ index >= visibleFieldIds.length - 1 } onClick={ () => { - onHide( field ); onChangeView( { ...view, - fields: visibleFieldIds.filter( - ( id ) => id !== fieldId - ), + fields: [ + ...( visibleFieldIds.slice( + 0, + index + ) ?? [] ), + visibleFieldIds[ index + 1 ], + fieldId, + ...visibleFieldIds.slice( index + 2 ), + ], } ); } } > - { __( 'Hide column' ) } + { __( 'Move right' ) } - ) } - - + { isHidable && field && ( + } + onClick={ () => { + onHide( field ); + onChangeView( { + ...view, + fields: visibleFieldIds.filter( + ( id ) => id !== fieldId + ), + } ); + } } + > + + { __( 'Hide column' ) } + + + ) } + + + ); } );