Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): make message link context menus usable with screen readers #10391

Closedakj(GitHub profile, opens in a new tab)wants to merge 13 commits intomain fromrefs/pull/10391/headopened View on GitHub

Showing 3 changed files with 143 additions and 0 deletions (loading 1).

x
0 of 3 viewed, 3 left
59 additions and 0 deletionsapps/web/src/components/chat/useMessageLinkMenu.test.tsxAdded
View file
@@ -0,0 +1,59 @@
+import { act, createRef, useImperativeHandle } from "react";
+import { create, type ReactTestRenderer } from "react-test-renderer";
+import { afterEach, describe, expect, it, vi } from "vite-plus/test";
+​
+import { useMessageLinkMenu } from "./useMessageLinkMenu";
+​
+let renderer: ReactTestRenderer | undefined;
+​
+afterEach(async () => {
+ await act(() => renderer?.unmount());
+ renderer = undefined;
+ vi.unstubAllGlobals();
+});
+​
+describe("message link menu positioning", () => {
+ it.each([
+ { position: { x: 0, y: 0 }, expected: { x: 120, y: 260 } },
+ { position: { x: 145, y: 245 }, expected: { x: 145, y: 245 } },
+ { position: { x: 0, y: 245 }, expected: { x: 0, y: 245 } },
+ { position: { x: 145, y: 0 }, expected: { x: 145, y: 0 } },
+ ])("anchors a menu opened at $position to $expected", async ({ position, expected }) => {
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ vi.stubGlobal(
+ "DOMRect",
+ class {
+ constructor(
+ readonly x: number,
+ readonly y: number,
+ readonly width: number,
+ readonly height: number,