Skip to content

Commit

Permalink
Close modals in schema designer on esc key press
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Aug 6, 2021
1 parent 0164273 commit bf3baf1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/IHP/static/IDE/ihp-schemadesigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function initSchemaDesigner() {
});

initEnumValueNameSnakeCaseCheck();
closeModalOnEscape();
}

function initCodeEditor() {
Expand Down Expand Up @@ -298,4 +299,16 @@ function initEnumValueNameSnakeCaseCheck() {
input.classList.remove('is-invalid');
}
}
}

function closeModalOnEscape() {
document.addEventListener('keydown', event => {
const escKey = 27;
if (event.keyCode != escKey) {
return;
}

const modalBackdrop = document.getElementById('modal-backdrop');
modalBackdrop?.click();
})
}

0 comments on commit bf3baf1

Please sign in to comment.