diff --git a/torchci/components/benchmark/v3/components/common/navigate.tsx b/torchci/components/benchmark/v3/components/common/navigate.tsx index 0069ae9361..0d1855d0f2 100644 --- a/torchci/components/benchmark/v3/components/common/navigate.tsx +++ b/torchci/components/benchmark/v3/components/common/navigate.tsx @@ -21,12 +21,11 @@ export async function navigateToDataGrid( openToggleSectionById(toggleId); await delay(350); // wait for toggle animation } - const target = scrollToDataGridView(sectionId, keywords, field); - await delay(300); // wait for scroll animation + const target = await scrollToDataGridView(sectionId, keywords, field); return target; } -function scrollToDataGridView( +async function scrollToDataGridView( sectionId: string, keywords: string[], field?: string @@ -58,7 +57,7 @@ function scrollToDataGridView( ); if (cell) { target = cell; - scrollingToElement(cell); + await scrollingToElement(cell); } } return target; @@ -85,7 +84,7 @@ export async function navigateToEchartInGroup( return null; } // scroll into view - scrollingToElement(target); + await scrollingToElement(target); return target; } @@ -94,11 +93,35 @@ export function getElementById(id: string): HTMLElement | null { return document.getElementById(id); } -export async function scrollingToElement( - target: HTMLElement | null, - delay_ts: number = 200 -) { +export async function scrollingToElement(target: HTMLElement | null) { if (!target) return null; target.scrollIntoView({ behavior: "smooth", block: "center" }); - await delay(delay_ts); + await waitUntilElementVisible(target); +} + +// Wait until element is visible in the viewport (with timeout) +export async function waitUntilElementVisible( + el: HTMLElement | null, + timeout = 1500 +): Promise { + if (!el) { + return; + } + const start = performance.now(); + return new Promise((resolve) => { + const check = () => { + const rect = el.getBoundingClientRect(); + const inView = + rect.top >= 0 && + rect.bottom <= + (window.innerHeight || document.documentElement.clientHeight); + + if (inView || performance.now() - start > timeout) { + resolve(); + } else { + requestAnimationFrame(check); + } + }; + requestAnimationFrame(check); + }); } diff --git a/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesChart/BenchmarkTimeSeriesChartGroup.tsx b/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesChart/BenchmarkTimeSeriesChartGroup.tsx index 08b908fa00..d1f6b7609d 100644 --- a/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesChart/BenchmarkTimeSeriesChartGroup.tsx +++ b/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesChart/BenchmarkTimeSeriesChartGroup.tsx @@ -89,13 +89,13 @@ export default function BenchmarkTimeSeriesChartGroup({ chartGroup?.chart ); - console.log(g.labels.join("-"), chartGroup?.sectionSelectMode); - const enableSelectMode = - chartGroup?.sectionSelectMode?.[g.labels.join("-")] ?? true; + const maxTimeSeries = groupSeries + .map((s) => s.data.length) + .reduce((a, b) => Math.max(a, b)); return ( 40 ? 12 : 6 }} id={toBenchmarkTimeseriesChartGroupId(g.key)} > diff --git a/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesComparisonSection/BenchmarkTimeSeriesComparisonTableSlider.tsx b/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesComparisonSection/BenchmarkTimeSeriesComparisonTableSlider.tsx index cbbc37bee8..89007713e1 100644 --- a/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesComparisonSection/BenchmarkTimeSeriesComparisonTableSlider.tsx +++ b/torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesComparisonSection/BenchmarkTimeSeriesComparisonTableSlider.tsx @@ -116,7 +116,7 @@ export function BenchmarkTimeSeriesComparisonTableSlider({ [ids, onChange] ); - const minWidth = Math.max(200, 50 * ids.length); + const minWidth = Math.min(200, 50 * ids.length); return ( diff --git a/torchci/components/benchmark/v3/configs/teams/compilers/CompilerPrecomputeConfirmDialogContent.tsx b/torchci/components/benchmark/v3/configs/teams/compilers/CompilerPrecomputeConfirmDialogContent.tsx index 76ce3cf13c..ee45926ba5 100644 --- a/torchci/components/benchmark/v3/configs/teams/compilers/CompilerPrecomputeConfirmDialogContent.tsx +++ b/torchci/components/benchmark/v3/configs/teams/compilers/CompilerPrecomputeConfirmDialogContent.tsx @@ -50,6 +50,7 @@ export const CompilerPrecomputeConfirmDialogContent: React.FC< const tableId = toBenchamrkTimeSeriesComparisonTableId( `metric=${left.metric}` ); + const table = getElementById(tableId); // if the table is not exist,scroll to the toggle section if (!table) { @@ -57,6 +58,7 @@ export const CompilerPrecomputeConfirmDialogContent: React.FC< triggerUpdate(); return; } + const cell = await navigateToDataGrid( tableId, [`${left?.compiler}`], diff --git a/torchci/components/benchmark/v3/pages/BenchmarkRegressionPage.tsx b/torchci/components/benchmark/v3/pages/BenchmarkRegressionPage.tsx index 3553be9385..d963223a5f 100644 --- a/torchci/components/benchmark/v3/pages/BenchmarkRegressionPage.tsx +++ b/torchci/components/benchmark/v3/pages/BenchmarkRegressionPage.tsx @@ -1,3 +1,4 @@ +import { Box } from "@mui/system"; import dayjs from "dayjs"; import utc from "dayjs/plugin/utc"; import { BenchmarkDashboardStoreProvider } from "lib/benchmark/store/benchmark_dashboard_provider"; @@ -19,12 +20,12 @@ export default function BenchmarkRegressionPage({ return ( -
+ -
+ -
-
+ +
); }