UX: ensures esc key is correctly working when in dates form (#9299)

1 esc close modal focus date button in toolbar
2 esc reduces composer
This commit is contained in:
Joffrey JAFFEUX 2020-03-30 17:59:25 +02:00 committed by GitHub
parent d0d5f0c912
commit 6c2717eda0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { schedule } from "@ember/runloop";
export default Controller.extend(ModalFunctionality, {
onShow() {
schedule("afterRender", () => {
const fromButton = document.getElementById("from-date-time");
fromButton && fromButton.focus();
});
},
onClose() {
schedule("afterRender", () => {
const localDatesBtn = document.querySelector(
".d-editor-button-bar .local-dates.btn"
);
localDatesBtn && localDatesBtn.focus();
});
}
});

View File

@ -23,6 +23,7 @@
<div class="date-time-control from {{if fromSelected 'is-selected'}} {{if fromFilled 'is-filled'}}">
{{d-icon "calendar-alt"}}
{{d-button
id="from-date-time"
action=(action "focusFrom")
translatedLabel=formattedFrom
class="date-time"}}