Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): a click no longer lands on the sidebar row that just slid under it #23517

Mergedmkantautas(GitHub profile, opens in a new tab)merged 13 commits intomain fromrefs/pull/23517/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 180 additions and 0 deletions (loading 2).

x
0 of 3 viewed, 3 left
180 additions and 0 deletionsapps/web/src/components/Sidebar.shiftGuard.browser.test.tsAdded
View file
@@ -0,0 +1,180 @@
+import { describe, expect, it, vi } from "vite-plus/test";
+import { userEvent } from "vite-plus/test/browser";
+import { fakeTimers, render } from "../../test/render";
+import { createSidebarShiftGuard } from "./Sidebar.shiftGuard";
+​
+function mountList(container: HTMLElement, names: readonly string[]) {
+ const list = document.createElement("ul");
+ list.style.cssText = "position: relative; margin: 0; padding: 0; width: 200px; list-style: none";
+ const pressed: string[] = [];
+ const rows = new Map<string, HTMLLIElement>();
+ const add = (name: string) => {
+ const row = document.createElement("li");
+ row.style.height = "40px";
+ const button = document.createElement("button");
+ button.textContent = name;
+ button.addEventListener("click", () => pressed.push(name));
+ row.append(button);
+ list.append(row);
+ rows.set(name, row);
+ };
+ for (const name of names) add(name);
+ container.append(list);
+ const guard = createSidebarShiftGuard(list);
+ return {
+ pressed,
+ guard,
+ button: (name: string) => rows.get(name)!.querySelector("button")!,
+ add,
+ remove: (name: string) => rows.get(name)!.remove(),
+ [Symbol.dispose]: () => guard.dispose(),