Skip to content

Commit

Permalink
UX: ensures esc key is correctly working when in dates form (#9299)
Browse files Browse the repository at this point in the history
1 esc close modal focus date button in toolbar
2 esc reduces composer
  • Loading branch information
jjaffeux committed Mar 30, 2020
1 parent d0d5f0c commit 6c2717e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
@@ -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();
});
}
});
Expand Up @@ -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"}}
Expand Down

0 comments on commit 6c2717e

Please sign in to comment.