|
1 | 1 | import { FModeManager } from '$lib/focus/fModeManager';
|
2 | 2 | import { getNavigationAction, isInputElement, getElementDescription } from '$lib/focus/focusUtils';
|
3 | 3 | import { focusNextTabIndex } from '$lib/focus/tabbable';
|
4 |
| -import { removeFromArray, scrollIntoViewIfNeeded } from '$lib/focus/utils'; |
| 4 | +import { isContentEditable, removeFromArray, scrollIntoViewIfNeeded } from '$lib/focus/utils'; |
5 | 5 | import { parseHotkey, matchesHotkey } from '$lib/utils/hotkeySymbols';
|
6 | 6 | import { mergeUnlisten } from '$lib/utils/mergeUnlisten';
|
7 | 7 | import { InjectionToken } from '@gitbutler/core/context';
|
@@ -91,14 +91,14 @@ export class FocusManager {
|
91 | 91 |
|
92 | 92 | if (e.target instanceof HTMLElement) {
|
93 | 93 | const focusableNode = this.findNearestFocusableElement(e.target);
|
94 |
| - if (focusableNode) { |
| 94 | + if (focusableNode && focusableNode.element.contains(e.target)) { |
95 | 95 | this.setActiveNode(focusableNode);
|
96 | 96 | this.setOutline(false);
|
97 | 97 | }
|
98 | 98 | }
|
99 | 99 |
|
100 | 100 | // TODO: Find a way to update the focusable without causing target to blur.
|
101 |
| - if (isInputElement(e.target)) { |
| 101 | + if (isInputElement(e.target) && !isContentEditable(e.target)) { |
102 | 102 | e.target.focus();
|
103 | 103 | }
|
104 | 104 | }
|
@@ -358,7 +358,9 @@ export class FocusManager {
|
358 | 358 |
|
359 | 359 | private updateCurrentNode(event: KeyboardEvent): FocusableNode | undefined {
|
360 | 360 | if (this.currentNode) return this.currentNode;
|
361 |
| - if (event.key === 'Tab') return; |
| 361 | + // We don't want to go from no current to picking nearest navigable |
| 362 | + // descendant when modifier keys are pressed. |
| 363 | + if (['Tab', 'Shift', 'Ctrl', 'Meta'].includes(event.key)) return; |
362 | 364 |
|
363 | 365 | const firstNode = this.findNavigableDescendant(this.getDefaultRoot());
|
364 | 366 | if (firstNode) {
|
|
0 commit comments