Skip to content

Commit d1b2172

Browse files
committed
fix(ui): respect semver filter when showing latest tag
The 'latest' tag was unconditionally added to visible results even when it didn't match the active semver filter. This caused versions like 7.6.0 to appear when filtering by ranges like '^7.5 <7.6'. Remove the special case handling for the 'latest' tag and let it flow naturally through the filtering logic. This makes the behavior more predictable and fixes the bug where non-matching versions were displayed.
1 parent 5324b96 commit d1b2172

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

app/components/Package/Versions.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,7 @@ const visibleTagRows = computed(() => {
210210
getTagVersions(row.tag).some(v => filteredVersionSet.value.has(v.version)),
211211
)
212212
: rowsMaybeFilteredForDeprecation
213-
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)
219-
}
220-
return first
213+
return rows.slice(0, MAX_VISIBLE_TAGS)
221214
})
222215
223216
// Hidden tag rows (all other tags) - shown in "Other versions"

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)