Skip to content

Commit

Permalink
fix: Suppress shortcuts in contenteditable elements (#77)
Browse files Browse the repository at this point in the history
* fix: Suppress shortcuts in contenteditable textbox
closes #76

* fix: Also disable shortcuts when activeElement is contenteditable
  • Loading branch information
tommoor authored Oct 18, 2021
1 parent e90865a commit 2f1de2b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/InternalEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ function useShortcuts() {

const activeElement = document.activeElement;
const ignoreStrokes =
activeElement &&
inputs.indexOf(activeElement.tagName.toLowerCase()) !== -1;
activeElement &&
(inputs.indexOf(activeElement.tagName.toLowerCase()) !== -1 ||
activeElement.attributes.getNamedItem("role")?.value === "textbox" ||
activeElement.attributes.getNamedItem("contenteditable")?.value ===
"true");

if (ignoreStrokes || event.metaKey || charList.indexOf(key) === -1) {
return;
Expand Down

1 comment on commit 2f1de2b

@vercel
Copy link

@vercel vercel bot commented on 2f1de2b Oct 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.