Table: Fixes logic for when adhoc filters are shown (#63642)

This commit is contained in:
Torkel Ödegaard 2023-03-06 11:14:55 +01:00 committed by GitHub
parent 95bd79ef4b
commit 30c6ac49ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -15,14 +15,14 @@ interface CellActionProps extends TableCellProps {
interface CommonButtonProps { interface CommonButtonProps {
size: IconSize; size: IconSize;
showFilters?: boolean;
tooltipPlacement: TooltipPlacement; tooltipPlacement: TooltipPlacement;
} }
export function CellActions({ field, cell, previewMode, onCellFilterAdded }: CellActionProps) { export function CellActions({ field, cell, previewMode, showFilters, onCellFilterAdded }: CellActionProps) {
const [isInspecting, setIsInspecting] = useState(false); const [isInspecting, setIsInspecting] = useState(false);
const isRightAligned = getTextAlign(field) === 'flex-end'; const isRightAligned = getTextAlign(field) === 'flex-end';
const showFilters = Boolean(field.config.filterable) && cell.value !== undefined;
const inspectEnabled = Boolean((field.config.custom as TableFieldOptions)?.inspect); const inspectEnabled = Boolean((field.config.custom as TableFieldOptions)?.inspect);
const commonButtonProps: CommonButtonProps = { const commonButtonProps: CommonButtonProps = {
size: 'sm', size: 'sm',

View File

@ -28,7 +28,7 @@ export const DefaultCell: FC<TableCellProps> = (props) => {
value = formattedValueToString(displayValue); value = formattedValueToString(displayValue);
} }
const showFilters = field.config.filterable; const showFilters = props.onCellFilterAdded && field.config.filterable;
const showActions = (showFilters && cell.value !== undefined) || inspectEnabled; const showActions = (showFilters && cell.value !== undefined) || inspectEnabled;
const cellOptions = getCellOptions(field); const cellOptions = getCellOptions(field);
const cellStyle = getCellStyle(tableStyles, cellOptions, displayValue, inspectEnabled); const cellStyle = getCellStyle(tableStyles, cellOptions, displayValue, inspectEnabled);
@ -56,7 +56,7 @@ export const DefaultCell: FC<TableCellProps> = (props) => {
</DataLinksContextMenu> </DataLinksContextMenu>
)} )}
{showActions && <CellActions {...props} previewMode="text" />} {showActions && <CellActions {...props} previewMode="text" showFilters={showFilters} />}
</div> </div>
); );
}; };