Skip to content

Commit f4806f7

Browse files
committed
Edit on enter
1 parent 186890a commit f4806f7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/app/content/highlights/components/CardWrapper.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ function useFocusedHighlight(
144144
}
145145
}, [focusedHighlight, document, dblclickStamp]);
146146

147+
// Let Enter go from a highlight to the editor
148+
const editOnEnter = React.useCallback(() => {
149+
if (focusedHighlight) {
150+
setShouldFocusCard(true);
151+
}
152+
}, [focusedHighlight]);
153+
147154
// This function is triggered by keyboard shortcut defined in useKeyCombination(...)
148155
// It moves focus between Card component and highlight in the content.
149156
const moveFocus = React.useCallback(({target}: KeyboardEvent) => {
@@ -156,6 +163,7 @@ function useFocusedHighlight(
156163
setShouldFocusCard(!cardIsFocused);
157164
}, [element, focusedHighlight]);
158165

166+
useKeyCombination({key: 'Enter'}, editOnEnter);
159167
useKeyCombination(highlightKeyCombination, moveFocus, noopKeyCombinationHandler([container, element]));
160168
// Clear shouldFocusCard when focus is lost from the CardWrapper.
161169
// If we don't do this then card related for the focused highlight will be focused automatically.

0 commit comments

Comments
 (0)