Skip to content

fix(ui): load all versions when semver range filter is entered#1912

Merged
serhalp merged 3 commits intomainfrom
serhalp/fix-prerelease-search
Mar 5, 2026
Merged

fix(ui): load all versions when semver range filter is entered#1912
serhalp merged 3 commits intomainfrom
serhalp/fix-prerelease-search

Conversation

@serhalp
Copy link
Member

@serhalp serhalp commented Mar 4, 2026

🔗 Linked issue

Closes #1828

🧭 Context

See #1828 — in some deterministic cases matching versions aren't shown when filtering a package's versions by a semver range.

📚 Description

It turns out there were two layered causes here:

  1. We were only loading a subset of versions. There was a code path to load all versions but we weren't triggering it. Now, entering a valid semver range triggers loading all versions and auto-expands the "Other versions" section. A guard prevents repeated fetches when typing subsequent valid ranges in the semver input.
  2. Tag rows were hidden when their "primary" version didn't match the filter, even if child versions did. For example, filtering for ~3.4.0 on vue hid the latest row (pointing to 3.5.13), making 3.4.0 invisible since it was "claimed" by (nested under) that tag and not in "Other versions". This just needed a fix to the filtering logic to take this into account.

The new integration test covers both.

Try it: https://npmx-g9g3y6w15-npmx.vercel.app/package/vue

Screenshot 2026-03-04 at 07 41 06 Screenshot 2026-03-04 at 07 42 03

(The new auto-expand behaviour is quite nicer, IMO!)

The semver filter only searched against the ~10 versions from the initial
SSR payload, so filtering for versions outside that set returned no
results. Now, entering a valid semver range triggers loading all versions
and auto-expands the "Other versions" section. A guard prevents redundant
fetches across subsequent filter changes.
@vercel
Copy link

vercel bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 4, 2026 8:14pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 4, 2026 8:14pm
npmx-lunaria Ignored Ignored Mar 4, 2026 8:14pm

Request Review

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Tag rows were hidden when their primary version didn't match the filter,
even if child versions did. For example, filtering for `~3.4.0` on vue
hid the `latest` row (pointing to 3.5.13), making 3.4.0 invisible since
it was claimed by that tag and not in "Other versions".

Now tag rows stay visible when any child version matches, and matching
children are auto-expanded when a filter is active. Also fixes the test
to exercise the real bug scenario (same-major child version).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

This PR updates the Package/Versions component to load and process all package versions when a valid semver filter is entered, auto-expanding tag groups whose primary or child versions match the filter. It adds helpers to map and retrieve tag-associated versions, caches loaded results to avoid repeated fetches, and integrates expansion state with ARIA and chevron UI. Rendering and visibility logic for tag rows and the "Other versions" section now consider both manual expansion and semver-driven expansion. Tests were added to validate valid/invalid semver handling and single-fetch behaviour.

Possibly related PRs

Suggested reviewers

  • danielroe
  • alexdln
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly relates to the changeset, describing the two root causes of semver filtering issues and how they were addressed in the Versions.vue and test files.
Linked Issues check ✅ Passed The PR successfully addresses both coding requirements from #1828: loading all versions when a semver range is entered, and fixing the filtering logic to show tag rows when child versions match.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing semver range filtering in the Versions component and adding corresponding tests; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch serhalp/fix-prerelease-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 105ccd8e-df56-4a1e-b2a2-fa1147299317

📥 Commits

Reviewing files that changed from the base of the PR and between 036dfc2 and 78864eb.

📒 Files selected for processing (2)
  • app/components/Package/Versions.vue
  • test/nuxt/components/PackageVersions.spec.ts

@ghostdevv
Copy link
Contributor

is this ready for review/merge? @serhalp

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/components/Package/Versions.vue (1)

616-621: ⚠️ Potential issue | 🟡 Minor

Keep the expand/collapse ARIA label in sync with effective expanded state.

Line 616 uses isTagExpanded(...) for aria-expanded, but Line 618 uses expandedTags.has(...) for the label. Under filter-driven expansion these can diverge, so assistive text can announce the wrong action.

Suggested patch
             :aria-label="
-              expandedTags.has(row.tag)
+              isTagExpanded(row.tag, row.primaryVersion.version)
                 ? $t('package.versions.collapse', { tag: row.tag })
                 : $t('package.versions.expand', { tag: row.tag })
             "

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e257437a-4f56-47ce-9961-fdeee5e01478

📥 Commits

Reviewing files that changed from the base of the PR and between 78864eb and 46aa394.

📒 Files selected for processing (1)
  • app/components/Package/Versions.vue

Comment on lines +119 to +133
// Load all versions when a valid semver filter is entered
watch(semverFilter, async newFilter => {
const trimmed = newFilter.trim()
if (trimmed === '' || hasLoadedAll.value) return
if (!validRange(trimmed)) return

try {
const allVersions = await loadAllVersions()
processLoadedVersions(allVersions)
// Auto-expand "Other versions" so filtered results are visible
otherVersionsExpanded.value = true
} catch {
// Silently fail — user can still use the filter with already-known versions
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Prevent stale watcher results from mutating UI after the filter has changed.

At Line 129, otherVersionsExpanded.value = true runs after await loadAllVersions(), even if the user has already changed/cleared the input. This can reopen “Other versions” unexpectedly with stale state.

Suggested patch
 watch(semverFilter, async newFilter => {
   const trimmed = newFilter.trim()
   if (trimmed === '' || hasLoadedAll.value) return
   if (!validRange(trimmed)) return

   try {
     const allVersions = await loadAllVersions()
+    // Ignore stale async runs if input changed while loading
+    if (semverFilter.value.trim() !== trimmed) return
     processLoadedVersions(allVersions)
     // Auto-expand "Other versions" so filtered results are visible
     otherVersionsExpanded.value = true
   } catch {
     // Silently fail — user can still use the filter with already-known versions
   }
 })

@serhalp serhalp added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 5530873 Mar 5, 2026
23 checks passed
@serhalp serhalp deleted the serhalp/fix-prerelease-search branch March 5, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No results matched when filtering by semver

3 participants