Skip to content

Commit

Permalink
Disable keyboard shortcuts when a <textarea> is focused
Browse files Browse the repository at this point in the history
Already applies to <input>
  • Loading branch information
GarboMuffin committed Aug 15, 2023
1 parent a10d2f2 commit 18b542c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/containers/paint-editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ class PaintEditor extends React.Component {
}
onMouseDown (event) {
if (event.target === paper.view.element &&
document.activeElement instanceof HTMLInputElement) {
(
document.activeElement instanceof HTMLInputElement ||
document.activeElement instanceof HTMLTextAreaElement
)
) {
document.activeElement.blur();
}

Expand Down
2 changes: 1 addition & 1 deletion src/helper/selection-tools/nudge-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class NudgeTool {
this.boundingBoxTool.isBitmap = mode in BitmapModes;
}
onKeyDown (event) {
if (event.event.target instanceof HTMLInputElement) {
if (event.event.target instanceof HTMLInputElement || event.event.target instanceof HTMLTextAreaElement) {
// Ignore nudge if a text input field is focused
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/helper/selection-tools/reshape-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class ReshapeTool extends paper.Tool {
this.active = false;
}
handleKeyDown (event) {
if (event.event.target instanceof HTMLInputElement) {
if (event.event.target instanceof HTMLInputElement || event.event.target instanceof HTMLTextAreaElement) {
// Ignore nudge if a text input field is focused
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/helper/tools/text-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class TextTool extends paper.Tool {
this.active = false;
}
handleKeyUp (event) {
if (event.event.target instanceof HTMLInputElement) {
if (event.event.target instanceof HTMLInputElement || event.event.target instanceof HTMLTextAreaElement) {
// Ignore nudge if a text input field is focused
return;
}
Expand All @@ -292,7 +292,7 @@ class TextTool extends paper.Tool {
}
}
handleKeyDown (event) {
if (event.event.target instanceof HTMLInputElement) {
if (event.event.target instanceof HTMLInputElement || event.event.target instanceof HTMLTextAreaElement) {
// Ignore nudge if a text input field is focused
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hocs/keyboard-shortcuts-hoc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const KeyboardShortcutsHOC = function (WrappedComponent) {
]);
}
handleKeyPress (event) {
if (event.target instanceof HTMLInputElement) {
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) {
// Ignore keyboard shortcuts if a text input field is focused
return;
}
Expand Down

0 comments on commit 18b542c

Please sign in to comment.