Skip to content

Commit 96589cf

Browse files
author
J.V
authored
Merge pull request #2 from coverhound/jv-modifies-logic-for-hiding-datepicker-on-back-button-press
Modifies logic to hide datepicker when clicking browser back button
2 parents e4834be + d67c20a commit 96589cf

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

input.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ export default class Input {
8989
});
9090
}
9191

92-
// when used in a single-page app,
93-
// hide datepicker when the browser's back button is pressed
94-
this.element.addEventListener("hashchange", () => {
95-
thePicker.hide();
96-
})
97-
9892
getLocaleText() {
9993
const locale = this.locale.toLowerCase();
10094

picker.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ class Picker {
129129
document.addEventListener(`mousedown`, this.removeClickOut);
130130
document.addEventListener(`touchstart`, this.removeClickOut);
131131
}, 500);
132+
133+
// when used in a single-page app or otherwise,
134+
// hide datepicker when the browser's back button is pressed
135+
window.onpopstate = () => {
136+
this.hide();
137+
}
132138
}
133139

134140
// Position picker below element. Align to element's right edge.

0 commit comments

Comments
 (0)