Skip to content

Fix browser back navigation when viewing a bitstream#5978

Open
jesielviana wants to merge 1 commit into
DSpace:mainfrom
LA-Referencia-Lyrasis-Project:fix-browser-back-from-bitstream
Open

Fix browser back navigation when viewing a bitstream#5978
jesielviana wants to merge 1 commit into
DSpace:mainfrom
LA-Referencia-Lyrasis-Project:fix-browser-back-from-bitstream

Conversation

@jesielviana

Copy link
Copy Markdown
Contributor

References

Description

Fixes bitstream browser-back behavior by allowing the Angular bitstream download route to activate before redirecting to the actual bitstream content URL.

Instructions for Reviewers

List of changes in this PR:

  • Removed the pre-activation guard from bitstream-page-routes.ts.
  • Added a focused route spec in bitstream-page-routes.spec.ts verifying:
    • The Angular bitstream download route activates without a pre-activation redirect guard.
    • Legacy bitstream URL routes still keep their redirect guards.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

Copilot AI review requested due to automatic review settings July 20, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts bitstream download routing so the Angular :id/download route can activate (and therefore be added to browser history) before performing the redirect to the bitstream content URL, addressing incorrect browser-back behavior when viewing a bitstream.

Changes:

  • Removed the pre-activation canActivate redirect guard from the Angular bitstream download route (:id/download).
  • Added a focused route-configuration spec to ensure the Angular download route has no pre-activation redirect guard while legacy bitstream URL routes retain their redirect guards.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/app/bitstream-page/bitstream-page-routes.ts Removes the pre-activation redirect guard from the Angular download route while keeping legacy routes guarded.
src/app/bitstream-page/bitstream-page-routes.spec.ts Adds unit tests asserting the new route-guard configuration for Angular vs legacy bitstream routes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 40 to 44
// Resolve angular bitstream download URLs
path: ':id/download',
component: BitstreamDownloadPageComponent,
resolve: {
bitstream: bitstreamPageResolver,
Comment on lines +1 to +13
import { BitstreamDownloadPageComponent } from './bitstream-download-page/bitstream-download-page.component';
import { bitstreamPageResolver } from './bitstream-page.resolver';
import { ROUTES } from './bitstream-page-routes';
import { legacyBitstreamURLRedirectGuard } from './legacy-bitstream-url-redirect.guard';

describe('bitstream page routes', () => {
it('should activate the Angular bitstream download page before redirecting to content', () => {
const downloadRoute = ROUTES.find((route) => route.path === ':id/download')!;

expect(downloadRoute).toBeDefined();
expect(downloadRoute.component).toBe(BitstreamDownloadPageComponent);
expect(downloadRoute.resolve?.bitstream).toBe(bitstreamPageResolver);
expect(downloadRoute.canActivate).toBeUndefined();
Comment on lines +16 to +23
it('should keep redirect guards on legacy bitstream URL routes', () => {
const legacyRoutes = ROUTES.filter((route) => route.path !== ':id/download' && route.component === BitstreamDownloadPageComponent);

expect(legacyRoutes.length).toBe(2);
legacyRoutes.forEach((route) => {
expect(route.canActivate).toContain(legacyBitstreamURLRedirectGuard);
});
});
@lgeggleston lgeggleston added bug usability 1 APPROVAL pull request only requires a single approval to merge component: Item (Archived) Item display or editing port to dspace-10_x This PR needs to be ported to `dspace-10_x` branch for next bug-fix release labels Jul 20, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 11.0 Release Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug component: Item (Archived) Item display or editing port to dspace-10_x This PR needs to be ported to `dspace-10_x` branch for next bug-fix release usability

Projects

Status: 🙋 Needs Reviewers Assigned

Development

Successfully merging this pull request may close these issues.

Browser back button does not navigate back to item when viewing a bitstream

3 participants