From 6e5af51c20ab94ba2432d0d9261db6c7f9378f02 Mon Sep 17 00:00:00 2001 From: graphieros Date: Wed, 11 Mar 2026 07:28:46 +0100 Subject: [PATCH] fix: handle CLS issues in chart modal --- app/components/Package/TrendsChart.vue | 300 ++++++++++++++++--------- 1 file changed, 189 insertions(+), 111 deletions(-) diff --git a/app/components/Package/TrendsChart.vue b/app/components/Package/TrendsChart.vue index 7d08014719..0907e36e4d 100644 --- a/app/components/Package/TrendsChart.vue +++ b/app/components/Package/TrendsChart.vue @@ -1345,12 +1345,54 @@ function drawSvgPrintLegend(svg: Record) { return seriesNames.join('\n') } +const showCorrectionControls = shallowRef(false) +const isResizing = shallowRef(false) + +const chartHeight = computed(() => { + if (isMobile.value) { + return 950 + } + return showCorrectionControls.value && props.inModal ? 494 : 600 +}) + +const timeoutId = shallowRef | null>(null) + +function pauseChartTransitions() { + if (timeoutId.value) { + clearTimeout(timeoutId.value) + } + + isResizing.value = true + + timeoutId.value = setTimeout(() => { + isResizing.value = false + timeoutId.value = null + }, 200) +} + +onBeforeUnmount(() => { + if (timeoutId.value) { + clearTimeout(timeoutId.value) + } +}) + +watch( + chartHeight, + (newH, oldH) => { + if (newH !== oldH) { + // Avoids triggering chart line transitions when the chart is resized + pauseChartTransitions() + } + }, + { immediate: true }, +) + // VueUiXy chart component configuration const chartConfig = computed(() => { return { theme: isDarkMode.value ? 'dark' : ('' as VueDataUiTheme), chart: { - height: isMobile.value ? 950 : 600, + height: chartHeight.value, backgroundColor: colors.value.bg, padding: { bottom: displayedGranularity.value === 'yearly' ? 84 : 64, right: 128 }, // padding right is set to leave space of last datapoint label(s) userOptions: { @@ -1554,7 +1596,6 @@ const chartConfig = computed(() => { }) const isDownloadsMetric = computed(() => selectedMetric.value === 'downloads') -const showCorrectionControls = shallowRef(false) const packageAnomalies = computed(() => getAnomaliesForPackages(effectivePackageNames.value)) const hasAnomalies = computed(() => packageAnomalies.value.length > 0) @@ -1674,116 +1715,139 @@ watch(selectedMetric, value => { /> {{ $t('package.trends.data_correction') }} -
- - - -
- - {{ $t('package.trends.known_anomalies') }} - -
@@ -1802,14 +1866,23 @@ watch(selectedMetric, value => {
{ [data-minimap-visible='false'] .vue-data-ui-watermark { top: calc(100% - 2rem) !important; } + +.no-transition line, +.no-transition circle { + transition: none !important; +}