diff --git a/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx b/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx index a31bd4ffe..e1e2ccd06 100644 --- a/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx +++ b/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx @@ -36,6 +36,7 @@ function DashboardMetricSelection(props: IProps) { const [activeCategory, setActiveCategory] = React.useState(); const [selectAllCheck, setSelectAllCheck] = React.useState(false); const selectedWidgetIds = useObserver(() => dashboardStore.selectedWidgets.map((widget: any) => widget.metricId)); + const scrollContainer = React.useRef(null); useEffect(() => { dashboardStore?.fetchTemplates(true).then((categories) => { @@ -43,6 +44,12 @@ function DashboardMetricSelection(props: IProps) { }); }, []); + useEffect(() => { + if (scrollContainer.current) { + scrollContainer.current.scrollTop = 0; + } + }, [activeCategory, scrollContainer.current]); + const handleWidgetCategoryClick = (category: any) => { setActiveCategory(category); setSelectAllCheck(false); @@ -100,6 +107,7 @@ function DashboardMetricSelection(props: IProps) {
{activeCategory && activeCategory.widgets.map((widget: any) => ( void; isWidget?: boolean; } -function WidgetWrapper(props: Props) { +function WidgetWrapper(props: Props & RouteComponentProps) { const { dashboardStore } = useStore(); const { isWidget = false, active = false, index = 0, moveListItem = null, isPreview = false, isTemplate = false, dashboardId, siteId } = props; const widget: any = useObserver(() => props.widget);