FIX: Allow dismissing Discard Drafts modal via ESC (#12532)
This commit is contained in:
parent
edc0f61920
commit
db7be947df
|
@ -51,7 +51,7 @@ export default Component.extend({
|
||||||
//only respond to events when the modal is visible
|
//only respond to events when the modal is visible
|
||||||
if (!this.element.classList.contains("hidden")) {
|
if (!this.element.classList.contains("hidden")) {
|
||||||
if (e.which === 27 && this.dismissable) {
|
if (e.which === 27 && this.dismissable) {
|
||||||
next(() => $(".modal-header button.modal-close").click());
|
next(() => this.attrs.closeModal("initiatedByESC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.which === 13 && this.triggerClickOnEnter(e)) {
|
if (e.which === 13 && this.triggerClickOnEnter(e)) {
|
||||||
|
@ -130,9 +130,7 @@ export default Component.extend({
|
||||||
this.set("dismissable", true);
|
this.set("dismissable", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.headerClass) {
|
this.set("headerClass", data.headerClass || null);
|
||||||
this.set("headerClass", data.headerClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.element) {
|
if (this.element) {
|
||||||
const autofocusInputs = this.element.querySelectorAll(
|
const autofocusInputs = this.element.querySelectorAll(
|
||||||
|
|
|
@ -3,6 +3,10 @@ import { isiPad } from "discourse/lib/utilities";
|
||||||
// A mixin where hitting ESC calls `cancelled` and ctrl+enter calls `save.
|
// A mixin where hitting ESC calls `cancelled` and ctrl+enter calls `save.
|
||||||
export default {
|
export default {
|
||||||
keyDown(e) {
|
keyDown(e) {
|
||||||
|
if (document.body.classList.contains("modal-open")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.which === 27) {
|
if (e.which === 27) {
|
||||||
this.cancelled();
|
this.cancelled();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{{#d-modal-body dismissable=false headerClass="empty"}}
|
{{#d-modal-body headerClass="hidden"}}
|
||||||
<div class="instructions">
|
<div class="instructions">
|
||||||
{{i18n "post.cancel_composer.confirm"}}
|
{{i18n "post.cancel_composer.confirm"}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -54,10 +54,8 @@
|
||||||
|
|
||||||
.modal-header {
|
.modal-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
&:not(.empty) {
|
padding: 10px 15px;
|
||||||
padding: 10px 15px;
|
border-bottom: 1px solid var(--primary-low);
|
||||||
border-bottom: 1px solid var(--primary-low);
|
|
||||||
}
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
|
|
Loading…
Reference in New Issue