mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-08 05:00:44 +08:00
Don’t leave line selected when switching blobs
Fixes #906 Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
This commit is contained in:
@@ -63,9 +63,10 @@
|
||||
</style>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div
|
||||
{title}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
on:click
|
||||
class="square-button"
|
||||
class:active
|
||||
|
||||
@@ -27,7 +27,10 @@
|
||||
$: content = highlighted ? lineNumbersGutter(highlighted) : undefined;
|
||||
|
||||
let selectedLineId: string | undefined = undefined;
|
||||
updateSelectedLineId();
|
||||
$: {
|
||||
content;
|
||||
updateSelectedLineId();
|
||||
}
|
||||
|
||||
function updateSelectedLineId() {
|
||||
const fragmentId = window.location.hash.substr(1);
|
||||
|
||||
@@ -101,19 +101,24 @@ test("source file highlighting", async ({ page }) => {
|
||||
|
||||
test("navigate line numbers", async ({ page }) => {
|
||||
await page.goto(`${markdownUrl}/tree/main/cheatsheet.md`);
|
||||
await page.locator('text="Plain"').click();
|
||||
await page.getByRole("button", { name: "Plain" }).click();
|
||||
|
||||
await page.locator('[href="#L5"]').click();
|
||||
await page.getByRole("link", { name: "5", exact: true }).click();
|
||||
await expect(page.locator("#L5")).toHaveClass("line highlight");
|
||||
await expect(page).toHaveURL(`${markdownUrl}/tree/main/cheatsheet.md#L5`);
|
||||
|
||||
await expectUrlPersistsReload(page);
|
||||
await expect(page.locator("#L5")).toHaveClass("line highlight");
|
||||
|
||||
await page.locator('[href="#L30"]').click();
|
||||
await page.getByRole("link", { name: "30", exact: true }).click();
|
||||
await expect(page.locator("#L5")).not.toHaveClass("line highlight");
|
||||
await expect(page.locator("#L30")).toHaveClass("line highlight");
|
||||
await expect(page).toHaveURL(`${markdownUrl}/tree/main/cheatsheet.md#L30`);
|
||||
|
||||
// Check that we go back to the Markdown view when navigating to a different
|
||||
// file.
|
||||
await page.getByRole("link", { name: "footnotes.md" }).click();
|
||||
await expect(page.getByRole("button", { name: "Plain" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("navigate deep file hierarchies", async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user