Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/dom/common/dom-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ abstract class DOMView<State extends DOMViewState, Data> {
let f = this._getFocusState();

if (key === 'Escape' && !this._resizingAnnotationID) {
let handled = false;
if (this._selectedAnnotationIDs.length) {
this._options.onSelectAnnotations([], event);
if (this._lastKeyboardFocusedAnnotationID) {
Expand All @@ -1011,14 +1012,23 @@ abstract class DOMView<State extends DOMViewState, Data> {
) as HTMLElement | SVGElement | null)
?.focus({ preventScroll: true });
}
handled = true;
}
else if (f.focusedElement) {
f.focusedElement.blur();
handled = true;
}
const selection = this._iframeWindow.getSelection();
if (selection && !selection.isCollapsed) {
selection.removeAllRanges();
handled = true;
}

// If Escape was handled locally (annotation selection/focus/text selection),
// don't forward it to common shortcuts.
if (handled) {
return;
}
this._iframeWindow.getSelection()?.removeAllRanges();
// The keyboard shortcut was handled here, therefore no need to
// pass it to this._onKeyDown(event) below
return;
}
else if (key === 'Shift-Tab') {
if (f.focusedElement) {
Expand Down
Loading