Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds simple keyboard accessibility to toggle popup on enter, close with escape key #80

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/components/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
@click="showCalendarByClick"
@focus="showCalendarByFocus"
@keyup="parseTypedDate"
@keyup.enter="toggleCalendar"
@keyup.escape="$emit('close-calendar')"
/>
<!-- Clear Button -->
<span
Expand Down Expand Up @@ -163,17 +165,7 @@ export default {
* Attempt to parse a typed date
* @param {Event} event
*/
parseTypedDate(event) {
const code = event.keyCode ? event.keyCode : event.which
// close calendar if escape or enter are pressed
if (
[
27, // escape
13, // enter
].indexOf(code) !== -1
) {
this.input.blur()
}
parseTypedDate() {
if (this.typeable) {
const parsableDate = this.parseDate(this.input.value)
const parsedDate = Date.parse(parsableDate)
Expand Down