Skip to content

Commit

Permalink
chore: add check if interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Dec 15, 2023
1 parent 88e2b9c commit dde72ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/ThreeDEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,20 @@ export class ThreeDEditor extends React.Component {
}

handleKeyPress = (e) => {
// Check if the event originated from an input, textarea, select, or CodeMirror
const { isInteractive, isThreejsEditorModalShown } = this.state;

// Check if interactive mode is off, or if the event originated from an input-like element
if (
!isInteractive ||
e.target.closest(".cm-editor") ||
["INPUT", "TEXTAREA", "SELECT"].includes(e.target.nodeName)
) {
return;
}

// In threejs editor modal, only listen to "e" key not to interfere with its own hotkeys
const { isThreejsEditorModalShown } = this.state;
if (isThreejsEditorModalShown) {
if (e.key.toLowerCase() === "e") {
this.toggleThreejsEditorModal();
}
// In threejs editor modal, only listen to "e" key
if (isThreejsEditorModalShown && e.key.toLowerCase() === "e") {
this.toggleThreejsEditorModal();
return;
}

Expand Down

0 comments on commit dde72ef

Please sign in to comment.