-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): retains search params when navigating back (#9576)
Closes #9132. When query params are present in the URL, such as after searching or filtering in the list view, they are not being retained after navigating back to that view via `history.back()` (i.e. the back button). This makes it difficult to quickly navigate in and out of documents from the list view when an underlying search exists. This was because the `SearchParamsProvider` is stale when the new view renders, which then replaces the URL with these stale params. The fix here is to _not_ use the `SearchParamsProvider` at all, and instead use `next/navigation` directly. Ultimately, this provider should likely be marked deprecated and then removed in the next major release for this very reason.
- Loading branch information
1 parent
3032273
commit 3961223
Showing
4 changed files
with
34 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import type { Page } from '@playwright/test' | ||
import type { AdminUrlUtil } from 'helpers/adminUrlUtil.js' | ||
|
||
export const navigateToDoc = async (page: Page, urlUtil: AdminUrlUtil) => { | ||
await page.goto(urlUtil.list) | ||
const regex = new RegExp(`^${urlUtil.list}(?:\\?.*)?$`) | ||
await page.waitForURL(regex) | ||
export const goToFirstCell = async (page: Page, urlUtil: AdminUrlUtil) => { | ||
const cellLink = page.locator(`tbody tr:first-child td a`).first() | ||
const linkURL = await cellLink.getAttribute('href') | ||
await page.goto(`${urlUtil.serverURL}${linkURL}`) | ||
await page.waitForURL(`**${linkURL}`) | ||
} | ||
|
||
export const navigateToDoc = async (page: Page, urlUtil: AdminUrlUtil) => { | ||
await page.goto(urlUtil.list) | ||
const regex = new RegExp(`^${urlUtil.list}(?:\\?.*)?$`) | ||
await page.waitForURL(regex) | ||
await goToFirstCell(page, urlUtil) | ||
} |