mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-27 18:10:58 +00:00
Fix g + h keyboard shortcut not working when a post is focused (#36935)
This commit is contained in:
parent
c22b203bca
commit
4d0aab4a31
|
|
@ -180,25 +180,24 @@ export function useHotkeys<T extends HTMLElement>(handlers: HandlerMap) {
|
||||||
|
|
||||||
if (shouldHandleEvent) {
|
if (shouldHandleEvent) {
|
||||||
const matchCandidates: {
|
const matchCandidates: {
|
||||||
handler: (event: KeyboardEvent) => void;
|
// A candidate will be have an undefined handler if it's matched,
|
||||||
|
// but handled in a parent component rather than this one.
|
||||||
|
handler: ((event: KeyboardEvent) => void) | undefined;
|
||||||
priority: number;
|
priority: number;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
(Object.keys(hotkeyMatcherMap) as HotkeyName[]).forEach(
|
(Object.keys(hotkeyMatcherMap) as HotkeyName[]).forEach(
|
||||||
(handlerName) => {
|
(handlerName) => {
|
||||||
const handler = handlersRef.current[handlerName];
|
const handler = handlersRef.current[handlerName];
|
||||||
|
const hotkeyMatcher = hotkeyMatcherMap[handlerName];
|
||||||
|
|
||||||
if (handler) {
|
const { isMatch, priority } = hotkeyMatcher(
|
||||||
const hotkeyMatcher = hotkeyMatcherMap[handlerName];
|
event,
|
||||||
|
bufferedKeys.current,
|
||||||
|
);
|
||||||
|
|
||||||
const { isMatch, priority } = hotkeyMatcher(
|
if (isMatch) {
|
||||||
event,
|
matchCandidates.push({ handler, priority });
|
||||||
bufferedKeys.current,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isMatch) {
|
|
||||||
matchCandidates.push({ handler, priority });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user