diff --git a/app/components/Compare/PackageSelector.vue b/app/components/Compare/PackageSelector.vue index 1d2acf69ca..a37978d7ff 100644 --- a/app/components/Compare/PackageSelector.vue +++ b/app/components/Compare/PackageSelector.vue @@ -8,7 +8,7 @@ const props = defineProps<{ max?: number }>() -const maxPackages = computed(() => props.max ?? 4) +const maxPackages = computed(() => props.max ?? MAX_PACKAGE_SELECTION) // Input state const inputValue = shallowRef('') diff --git a/app/components/Package/TrendsChart.vue b/app/components/Package/TrendsChart.vue index 005583283e..e81a32d804 100644 --- a/app/components/Package/TrendsChart.vue +++ b/app/components/Package/TrendsChart.vue @@ -1896,11 +1896,13 @@ const isSparklineLayout = computed({ role="region" aria-labelledby="trends-chart-title" :class=" - isMobile === false && width > 0 - ? showCorrectionControls - ? 'h-[491px]' - : 'h-[567px]' - : 'min-h-[260px]' + isSparklineLayout || !inModal + ? undefined + : isMobile === false && width > 0 + ? showCorrectionControls + ? 'h-[491px]' + : 'h-[567px]' + : 'min-h-[260px]' " > diff --git a/app/composables/usePackageSelection.ts b/app/composables/usePackageSelection.ts index 2e431abc7e..d677f4288a 100644 --- a/app/composables/usePackageSelection.ts +++ b/app/composables/usePackageSelection.ts @@ -1,4 +1,4 @@ -export const MAX_PACKAGE_SELECTION = 4 +export const MAX_PACKAGE_SELECTION = 10 export function usePackageSelection() { const selectedPackagesParam = useRouteQuery('selection', '', { mode: 'replace' }) diff --git a/app/pages/compare.vue b/app/pages/compare.vue index 4d37296971..655a63f5fa 100644 --- a/app/pages/compare.vue +++ b/app/pages/compare.vue @@ -10,7 +10,6 @@ definePageMeta({ const { locale } = useI18n() const { copied, copy } = useClipboard({ copiedDuring: 2000 }) -const maxPackages = 4 // Sync packages with URL query param (stable ref - doesn't change on other query changes) const packagesParam = useRouteQuery('packages', '', { mode: 'replace' }) @@ -23,7 +22,7 @@ const packages = computed({ .split(',') .map(p => p.trim()) .filter(p => p.length > 0) - .slice(0, maxPackages) + .slice(0, MAX_PACKAGE_SELECTION) }, set(value) { packagesParam.value = value.length > 0 ? value.join(',') : '' @@ -61,12 +60,12 @@ const gridColumns = computed(() => // Whether we can add the no-dep column (not already added and have room) const canAddNoDep = computed( - () => packages.value.length < maxPackages && !packages.value.includes(NO_DEPENDENCY_ID), + () => packages.value.length < MAX_PACKAGE_SELECTION && !packages.value.includes(NO_DEPENDENCY_ID), ) // Add "no dependency" column to comparison function addNoDep() { - if (packages.value.length >= maxPackages) return + if (packages.value.length >= MAX_PACKAGE_SELECTION) return if (packages.value.includes(NO_DEPENDENCY_ID)) return packages.value = [...packages.value, NO_DEPENDENCY_ID] } @@ -183,7 +182,7 @@ useSeoMeta({

{{ $t('compare.packages.section_packages') }}

- +
diff --git a/test/nuxt/components/compare/PackageSelector.spec.ts b/test/nuxt/components/compare/PackageSelector.spec.ts index 54eece3168..397107e57f 100644 --- a/test/nuxt/components/compare/PackageSelector.spec.ts +++ b/test/nuxt/components/compare/PackageSelector.spec.ts @@ -185,8 +185,8 @@ describe('PackageSelector', () => { it('respects max packages limit', async () => { const component = await mountSuspended(PackageSelector, { props: { - modelValue: ['a', 'b', 'c', 'd'], - max: 4, + modelValue: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], + max: 10, }, }) @@ -200,19 +200,19 @@ describe('PackageSelector', () => { const component = await mountSuspended(PackageSelector, { props: { modelValue: ['lodash', 'underscore'], - max: 4, + max: 10, }, }) expect(component.text()).toContain('2') - expect(component.text()).toContain('4') + expect(component.text()).toContain('10') }) it('shows add hint when less than 2 packages', async () => { const component = await mountSuspended(PackageSelector, { props: { modelValue: ['lodash'], - max: 4, + max: 10, }, }) @@ -222,15 +222,15 @@ describe('PackageSelector', () => { }) describe('max prop', () => { - it('defaults to 4 when not provided', async () => { + it('defaults to 10 when not provided', async () => { const component = await mountSuspended(PackageSelector, { props: { modelValue: [], }, }) - // Should show max of 4 in hint - expect(component.text()).toContain('4') + // Should show max of 10 in hint + expect(component.text()).toContain('10') }) it('uses provided max value', async () => {