Skip to content

Commit e9fe0a8

Browse files
committed
fixup! fixup! ✨(frontend) enable enter key to open documents and subdocuments
1 parent ee66426 commit e9fe0a8

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/frontend/apps/impress/src/features/docs/doc-tree/components/DocSubPageItem.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
8787
}
8888
};
8989

90-
useKeyboardActivation(['Enter'], isActive && !menuOpen, handleActivate, true);
90+
useKeyboardActivation(
91+
['Enter'],
92+
isActive && !menuOpen,
93+
handleActivate,
94+
true,
95+
'.c__tree-view',
96+
);
9197

9298
const docTitle = doc.title || untitledDocument;
9399
const hasChildren = (doc.children?.length || 0) > 0;

src/frontend/apps/impress/src/features/docs/doc-tree/components/dom-selectors.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { useEffect } from 'react';
22

3-
import { SELECTORS } from '../components/dom-selectors';
4-
53
export const useKeyboardActivation = (
64
keys: string[],
75
enabled: boolean,
86
action: () => void,
97
capture = false,
8+
selector: string,
109
) => {
1110
useEffect(() => {
1211
if (!enabled) {
@@ -18,13 +17,13 @@ export const useKeyboardActivation = (
1817
action();
1918
}
2019
};
21-
const treeEl = document.querySelector<HTMLElement>('.c__tree-view');
20+
const treeEl = document.querySelector<HTMLElement>(selector);
2221
if (!treeEl) {
2322
return;
2423
}
2524
treeEl.addEventListener('keydown', onKeyDown, capture);
2625
return () => {
2726
treeEl.removeEventListener('keydown', onKeyDown, capture);
2827
};
29-
}, [keys, enabled, action, capture]);
28+
}, [keys, enabled, action, capture, selector]);
3029
};

0 commit comments

Comments
 (0)