esc closes help + small bug fix

This commit is contained in:
Cade Scroggins 2017-03-03 20:03:53 -08:00
parent 197dd510b1
commit 18f2fdbf6c

View file

@ -277,13 +277,8 @@
<script>
const $ = {
el: s => {
return document.querySelector(s);
},
els: s => {
return document.querySelectorAll(s);
},
el: s => document.querySelector(s),
els: s => document.querySelectorAll(s),
};
class Clock {
@ -314,7 +309,9 @@
constructor() {
this._overlayEl = $.el('#js-overlay');
this._listsEl = $.el('#js-lists');
this._handleKeydown = this._handleKeydown.bind(this);
this._buildAndAppendLists();
this._registerEvents();
}
toggle(show) {
@ -346,6 +343,14 @@
</li>`
)).join('');
}
_handleKeydown(event) {
if (event.which === 27) this.toggle(false);
}
_registerEvents() {
document.addEventListener('keydown', this._handleKeydown);
}
}
class History {
@ -482,7 +487,7 @@
}
_focusNext() {
if (this._suggestionEls) {
if (this._suggestionEls.length) {
const active = document.activeElement;
if (active.classList.contains('js-search-suggestion')) {
@ -497,7 +502,7 @@
}
_focusPrevious() {
if (this._suggestionEls) {
if (this._suggestionEls.length) {
const active = document.activeElement;
if (active.classList.contains('js-search-suggestion')) {