Repository navigation
fix(web): make message link context menus usable with screen readers #10391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
806f7ff
fix(desktop): focus message link menus opened with the keyboard
akj 354fb35
fix(web): keep message link menu focus in the page
akj da4ce6f
Merge branch 'main' into fix/desktop-link-menu-focus
akj defea38
chore: merge main into fix/desktop-link-menu-focus
akj 75c7277
fix(web): anchor keyboard link menus beside their trigger
akj 79baca9
chore: merge latest main into fix/desktop-link-menu-focus
akj 0959e55
chore: sync link menu fix with main
akj 22b0776
chore: merge main into fix/desktop-link-menu-focus
akj 92ffacd
chore: merge main into fix/desktop-link-menu-focus
akj 95d43c5
chore: merge main into fix/desktop-link-menu-focus
akj 6c1f9a9
chore: merge main into fix/desktop-link-menu-focus
akj 4e96186
chore: merge main into fix/desktop-link-menu-focus
akj 52e16ff
chore: merge main into fix/desktop-link-menu-focus
akj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -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, | ||
| ) {} | ||
| }, | ||
| ); | ||
| const linkMenuRef = createRef<ReturnType<typeof useMessageLinkMenu>>(); | ||
| function TestLinkMenu() { | ||
| const linkMenu = useMessageLinkMenu(); | ||
| useImperativeHandle(linkMenuRef, () => linkMenu, [linkMenu]); | ||
| return null; | ||
| } | ||
| const trigger = { | ||
| getBoundingClientRect: () => ({ left: 120, bottom: 260 }), | ||
| } as HTMLElement; | ||
|
|
||
| await act(() => { | ||
| renderer = create(<TestLinkMenu />); | ||
| }); | ||
| await act(() => { | ||
| void linkMenuRef.current!.show([{ id: "copy-link", label: "Copy Link" }], position, trigger); | ||
| }); | ||
|
|
||
| // Evaluate the virtual anchor consumed by the popup's positioning engine. | ||
| const popup = linkMenuRef.current!.menu?.props.children; | ||
| expect(popup.props.anchor.getBoundingClientRect()).toMatchObject({ | ||
| ...expected, | ||
| width: 0, | ||
| height: 0, | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.