Skip to content

Commit

Permalink
Merge pull request #142 from Exabyte-io/hotfix/conditionally-disable-…
Browse files Browse the repository at this point in the history
…hotkeys

chore: add check if interactive + bonds redraw on wave instance change
  • Loading branch information
VsevolodX committed Dec 15, 2023
2 parents db6d65e + d154503 commit 6522012
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/components/ThreeDEditor.jsx
Expand Up @@ -172,23 +172,18 @@ 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)
["INPUT", "TEXTAREA", "SELECT"].includes(e.target.nodeName) ||
isThreejsEditorModalShown
) {
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();
}
return;
}

const handler = this.keyConfig[e.key.toLowerCase()];
if (handler) {
handler.call(this);
Expand Down
1 change: 1 addition & 0 deletions src/mixins/bonds.js
Expand Up @@ -181,6 +181,7 @@ export const BondsMixin = (superclass) =>
* We need this to block the UI until the bonds are drawn.
*/
drawBonds() {
this.createBondsAsync();
if (!this.areBondsCreated) {
this.bondsGroup = this.createBondsGroup();
this.areBondsCreated = true;
Expand Down

0 comments on commit 6522012

Please sign in to comment.