Skip to content

Commit

Permalink
Merge pull request #2 from coverhound/jv-modifies-logic-for-hiding-da…
Browse files Browse the repository at this point in the history
…tepicker-on-back-button-press

Modifies logic to hide datepicker when clicking browser back button
  • Loading branch information
J.V authored May 22, 2017
2 parents e4834be + d67c20a commit 96589cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions input.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ export default class Input {
});
}

// when used in a single-page app,
// hide datepicker when the browser's back button is pressed
this.element.addEventListener("hashchange", () => {
thePicker.hide();
})

getLocaleText() {
const locale = this.locale.toLowerCase();

Expand Down
6 changes: 6 additions & 0 deletions picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ class Picker {
document.addEventListener(`mousedown`, this.removeClickOut);
document.addEventListener(`touchstart`, this.removeClickOut);
}, 500);

// when used in a single-page app or otherwise,
// hide datepicker when the browser's back button is pressed
window.onpopstate = () => {
this.hide();
}
}

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

0 comments on commit 96589cf

Please sign in to comment.