Skip to content

Commit

Permalink
refactor(docs-viewer): disable global keyboard navigation in editable…
Browse files Browse the repository at this point in the history
… element

cheery pick 0f14c93
  • Loading branch information
hyrious committed May 30, 2023
1 parent c0a9be8 commit 5553aa7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/app-docs-viewer/src/StaticDocsViewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,17 @@ export class StaticDocsViewer {
"whiteboard-size-update"
);

const isEditable = (el: EventTarget | null) => {
if (!el) return false;
const tagName = (el as HTMLElement).tagName;
return tagName === "INPUT" || tagName === "TEXTAREA" || tagName === "SELECT";
};

this.sideEffect.addEventListener(
window,
"keyup",
ev => {
if (this.readonly$.value || !this.box.focus || this.box.minimized) {
if (this.readonly$.value || !this.box.focus || this.box.minimized || isEditable(ev.target)) {
return;
}
switch (ev.key) {
Expand Down
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5553aa7

Please sign in to comment.