Fix commits list ref selector
What does this MR do and why?
Fixes two bugs in the commits page ref selector:
-
Ref changes didn't refetch commits - Switching branches/tags via the ref selector only updated the URL but didn't trigger a new GraphQL query, so stale commits remained on screen. This was because the Apollo query used the injected
escapedRef(a constant) instead of a reactive data property. Now,commit_list_headeremits aref-changeevent, andcommit_list_appupdates a reactivecurrentRefand resets pagination accordingly. -
Refs with
#were incorrectly encoded -generateRouterParamsused an inlineencodeURI().replace(/#/g, '%23')instead of the existingencodeRepositoryPath()utility. This is now consolidated to use the shared helper, reducing duplication.
References
Closes #589360 (closed)
Screenshots or screen recordings
| before | after |
|---|---|
How to set up and validate locally
- Enable
project_commits_refactor - Navigate to any project's commits page (e.g.,
/-/commits/main) - Use the ref selector dropdown to switch to a different branch
- Before: The URL updates but the commit list stays the same
- After: The commit list refetches and displays commits for the selected branch, pagination resets
- Test with a branch name containing
#(e.g.,fix/#123) to verify correct URL encoding
Edited by Jacques Erasmus