diff --git a/x-pack/solutions/security/plugins/security_solution/public/detections/components/alerts_table/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/detections/components/alerts_table/index.tsx index 7a39c6ea0439f..ff64de77ba1da 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detections/components/alerts_table/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detections/components/alerts_table/index.tsx @@ -278,6 +278,25 @@ export const AlertsTableComponent: FC = ({ }; }, [isEventRenderedView]); + /** + * if records are too less, we don't want table to be of fixed height. + * it should shrink to the content height. + * Height setting enables/disables virtualization depending on fixed/undefined height values respectively. + * */ + const alertTableHeight = useMemo( + () => + isEventRenderedView + ? `${DEFAULT_DATA_GRID_HEIGHT}px` + : /* + * We keep fixed height in Event rendered because of the row height issue + * as mentioned here + */ + count > 20 + ? `${DEFAULT_DATA_GRID_HEIGHT}px` + : undefined, + [count, isEventRenderedView] + ); + const alertStateProps: AlertsTableStateProps = useMemo( () => ({ alertsTableConfigurationRegistry: triggersActionsUi.alertsTableConfigurationRegistry, @@ -296,10 +315,7 @@ export const AlertsTableComponent: FC = ({ cellContext, onLoaded: onLoad, toolbarVisibility, - // if records are too less, we don't want table to be of fixed height. - // it should shrink to the content height. - // Height setting enables/disables virtualization depending on fixed/undefined height values respectively. - height: count >= 20 ? `${DEFAULT_DATA_GRID_HEIGHT}px` : undefined, + height: alertTableHeight, initialPageSize: 50, runtimeMappings: sourcererDataView.runtimeFieldMap as RunTimeMappings, }), @@ -316,8 +332,8 @@ export const AlertsTableComponent: FC = ({ cellContext, onLoad, toolbarVisibility, - count, sourcererDataView.runtimeFieldMap, + alertTableHeight, ] );