Skip to content

New: [AEA-6483] - Redirect and navigate away protection for search result pages#1987

Open
connoravo-nhs wants to merge 19 commits intomainfrom
AEA-5500-redirect-protect
Open

New: [AEA-6483] - Redirect and navigate away protection for search result pages#1987
connoravo-nhs wants to merge 19 commits intomainfrom
AEA-5500-redirect-protect

Conversation

@connoravo-nhs
Copy link
Copy Markdown
Contributor

Summary

  • ✨ New Feature

Details

Introduce unload prevent default protections on the search result and prescription details pages.
Help to prevent accidental navigate away when search result information is on screen.

Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
…e page

Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
… to the search

Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 07:56
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

This PR is linked to a ticket in an NHS Digital JIRA Project. Here's a handy link to the ticket:

AEA-6483

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds “navigate away” protection for pages that show potentially important search/prescription information, and adjusts session-timeout UX/behavior (especially on the “select your role” page) with updated tests.

Changes:

  • Register/clear a global beforeunload guard from search results and prescription list/details pages.
  • Update session-timeout logic and modal content for the “Select your role” route, including improved accessibility messaging and button labeling.
  • Add/adjust tests and mocks to support router-dependent hooks/components and new redirect behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/cpt-ui/src/pages/PrescriptionListPage.tsx Registers/unregisters beforeunload guard after successful prescription list load.
packages/cpt-ui/src/pages/PrescriptionDetailsPage.tsx Registers/unregisters beforeunload guard after successful prescription details load.
packages/cpt-ui/src/pages/BasicDetailsSearchResultsPage.tsx Adds redirect on missing search params and registers beforeunload guard after payload.
packages/cpt-ui/src/hooks/useSessionTimeout.ts Changes “stay logged in” behavior on select-role path; uses location-derived path.
packages/cpt-ui/src/context/NavigationProvider.tsx Adds diagnostic logging when relevant search parameters aren’t available.
packages/cpt-ui/src/context/AuthProvider.tsx Introduces registerBeforeUnloadGuard / clearBeforeUnloadGuard in auth context.
packages/cpt-ui/src/constants/ui-strings/SessionTimeoutModalStrings.ts Adds strings for select-role instruction and “Close” label.
packages/cpt-ui/src/components/SessionTimeoutModal.tsx Route-aware modal messaging/button label and aria-live announcement adjustments.
packages/cpt-ui/src/components/prescriptionSearch/BasicDetailsSearch.tsx Clears beforeunload guard via effect cleanup.
packages/cpt-ui/tests/useSessionTimeout.test.tsx Wraps hook tests with MemoryRouter; adds select-role-path scenario.
packages/cpt-ui/tests/SessionTimeoutModal.test.tsx Wraps modal tests with MemoryRouter; adds select-role-path assertions.
packages/cpt-ui/tests/mocks/AuthStateMock.tsx Extends auth mock with beforeunload guard functions.
packages/cpt-ui/tests/BasicDetailsSearchResultsPage.test.tsx Updates default search state and adds redirect test for missing parameters.

connoravo-nhs and others added 5 commits April 2, 2026 09:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Search.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…UT. Fix redirection catch

Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
…/eps-prescription-tracker-ui into AEA-5500-redirect-protect
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

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.

2 participants