Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Don’t leave line selected when switching blobs
Thomas Scholtes committed 2 years ago
commit 092f8ad7744e360d74e346be234843bac32bb368
parent e0e659f54a930938b4086658a7fcaa59ce578551
3 files changed +14 -5
modified src/components/SquareButton.svelte
@@ -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
modified src/views/projects/Blob.svelte
@@ -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);
modified tests/e2e/project.spec.ts
@@ -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 }) => {