Skip to content

Commit 051f8a7

Browse files
authored
fix(ui): respect semver filter when showing latest tag (#2389)
1 parent 5324b96 commit 051f8a7

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

app/components/Package/Versions.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,16 @@ const visibleTagRows = computed(() => {
211211
)
212212
: rowsMaybeFilteredForDeprecation
213213
const first = rows.slice(0, MAX_VISIBLE_TAGS)
214-
const latestTagRow = rows.find(row => row.tag === 'latest')
215-
// Ensure 'latest' tag is always included (at the end) if not already present
216-
if (latestTagRow && !first.includes(latestTagRow)) {
217-
first.pop()
218-
first.push(latestTagRow)
214+
215+
// When no filter is active, ensure 'latest' is always shown (even if not fully loaded)
216+
if (!isFilterActive.value) {
217+
const latestTagRow = rows.find(row => row.tag === 'latest')
218+
if (latestTagRow && !first.includes(latestTagRow)) {
219+
first.pop()
220+
first.push(latestTagRow)
221+
}
219222
}
223+
220224
return first
221225
})
222226

test/nuxt/components/Package/Versions.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,21 @@ describe('PackageVersions', () => {
12811281
expect(text).not.toContain('0.5.0')
12821282
})
12831283
})
1284+
1285+
it('does not show latest tag when it does not match the filter', async () => {
1286+
const component = await mountSuspended(PackageVersions, { props: multiVersionProps })
1287+
1288+
const input = component.find('input[type="text"]')
1289+
await input.setValue('^1.0.0 <2.0.0')
1290+
1291+
const versionLinks = component.findAll('a').filter(isVersionLink)
1292+
const versions = versionLinks.map(l => l.text())
1293+
1294+
// 3.0.0 is latest but does NOT match the filter
1295+
expect(versions).not.toContain('3.0.0')
1296+
// 1.0.0 does match
1297+
expect(versions).toContain('1.0.0')
1298+
})
12841299
})
12851300

12861301
describe('error handling', () => {

0 commit comments

Comments
 (0)