New: [AEA-6483] - Redirect and navigate away protection for search result pages#1987
Open
connoravo-nhs wants to merge 19 commits intomainfrom
Open
New: [AEA-6483] - Redirect and navigate away protection for search result pages#1987connoravo-nhs wants to merge 19 commits intomainfrom
connoravo-nhs wants to merge 19 commits intomainfrom
Conversation
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>
… 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>
Contributor
|
This PR is linked to a ticket in an NHS Digital JIRA Project. Here's a handy link to the ticket: AEA-6483 |
Contributor
There was a problem hiding this comment.
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
beforeunloadguard 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. |
packages/cpt-ui/src/components/prescriptionSearch/BasicDetailsSearch.tsx
Outdated
Show resolved
Hide resolved
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>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
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.