Skip to content

Commit d6dafdd

Browse files
committed
feat: fix copy button appearing too soon
1 parent 874fda4 commit d6dafdd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/pages/compare.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,16 @@ function addNoDep() {
7575
// Get loading state for each column
7676
const columnLoading = computed(() => packages.value.map((_, i) => isColumnLoading(i)))
7777
78-
// FIXME(serhalp): canCompare only checks package count, not whether data has loaded.
79-
// Copy-markdown and view-switching commands appear as soon as one package loads, even if
80-
// other packages are still loading. The UI copy button has the same issue.
78+
// Makes sense to compare if there's 2 or more packages
8179
const canCompare = computed(() => packages.value.length >= 2)
8280
81+
// Allow copying only after all data is loaded
82+
const canCopyTable = computed(
83+
() =>
84+
packagesData.value.length >= 1 &&
85+
packagesData.value.every(data => data !== null && data !== undefined),
86+
)
87+
8388
const comparisonView = usePermalink<'table' | 'charts'>('view', 'table')
8489
const hasChartableFacets = computed(() => selectedFacets.value.some(facet => facet.chartable))
8590
@@ -173,7 +178,7 @@ useCommandPaletteContextCommands(
173178
},
174179
]
175180
176-
if (canCompare.value && packagesData.value && packagesData.value.some(p => p !== null)) {
181+
if (canCompare.value && canCopyTable.value) {
177182
commands.push({
178183
id: 'compare-copy-markdown',
179184
group: 'actions',
@@ -335,7 +340,7 @@ useSeoMeta({
335340
<!-- Comparison grid -->
336341
<section v-if="canCompare" class="mt-10" aria-labelledby="comparison-heading">
337342
<CopyToClipboardButton
338-
v-if="packagesData && packagesData.some(p => p !== null)"
343+
v-if="canCopyTable"
339344
:copied="copied"
340345
:copy-text="$t('compare.packages.copy_as_markdown')"
341346
class="mb-4"

0 commit comments

Comments
 (0)