Merge pull request #2831 from robintown/shortcut-modifiers

Don't trigger keyboard shortcuts if modifiers are held
This commit is contained in:
Robin 2024-11-22 13:25:24 -05:00 committed by GitHub
commit 1bbbd519c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -93,6 +93,16 @@ test("reactions can be sent via keyboard presses", async () => {
}
});
test("reaction is not sent when modifier key is held", async () => {
const user = userEvent.setup();
const sendReaction = vi.fn();
render(<TestComponent sendReaction={sendReaction} />);
await user.keyboard("{Meta>}1{/Meta}");
expect(sendReaction).not.toHaveBeenCalled();
});
test("raised hand can be sent via keyboard presses", async () => {
const user = userEvent.setup();

View File

@ -43,6 +43,8 @@ export function useCallViewKeyboardShortcuts(
(event: KeyboardEvent) => {
if (focusElement.current === null) return;
if (!mayReceiveKeyEvents(focusElement.current)) return;
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
return;
if (event.key === "m") {
event.preventDefault();