From 96222de5bc521ed212d4b63d6a25925fce500c80 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sun, 4 Aug 2024 11:06:42 +0530 Subject: [PATCH] fix page up/down button not working (#1863) --- src/app/features/room/Room.tsx | 3 ++- src/app/features/room/RoomView.tsx | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/features/room/Room.tsx b/src/app/features/room/Room.tsx index ee3e702..a4ec716 100644 --- a/src/app/features/room/Room.tsx +++ b/src/app/features/room/Room.tsx @@ -13,6 +13,7 @@ import { useKeyDown } from '../../hooks/useKeyDown'; import { markAsRead } from '../../../client/action/notifications'; import { useMatrixClient } from '../../hooks/useMatrixClient'; import { useRoomMembers } from '../../hooks/useRoomMembers'; +import { editableActiveElement } from '../../utils/dom'; export function Room() { const { eventId } = useParams(); @@ -28,7 +29,7 @@ export function Room() { window, useCallback( (evt) => { - if (isKeyHotkey('escape', evt)) { + if (isKeyHotkey('escape', evt) && !editableActiveElement()) { markAsRead(mx, room.roomId); } }, diff --git a/src/app/features/room/RoomView.tsx b/src/app/features/room/RoomView.tsx index 3eabd52..250afc9 100644 --- a/src/app/features/room/RoomView.tsx +++ b/src/app/features/room/RoomView.tsx @@ -25,6 +25,7 @@ const shouldFocusMessageField = (evt: KeyboardEvent): boolean => { if (evt.metaKey || evt.altKey || evt.ctrlKey) { return false; } + // do not focus on F keys if (/^F\d+$/.test(code)) return false; @@ -36,6 +37,9 @@ const shouldFocusMessageField = (evt: KeyboardEvent): boolean => { code.startsWith('Alt') || code.startsWith('Control') || code.startsWith('Arrow') || + code.startsWith('Page') || + code.startsWith('End') || + code.startsWith('Home') || code === 'Tab' || code === 'Space' || code === 'Enter' ||