Skip to content

Commit bdb9520

Browse files
authored
This fixes the sidebar on mobile view, as it stops hiding the sidebar on every size change, as the displaying of the keyboard, changes the viewable size, but should not collapse the sidebar again, as otherwise a search is impossible (#46)
Signed-off-by: Kai Wagner <[email protected]>
1 parent 5cb6421 commit bdb9520

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/javascript/controllers/sidebar_controller.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default class extends Controller {
1515
this.handleDocumentClick = this.handleDocumentClick.bind(this)
1616
window.addEventListener("resize", this.handleWindowResize)
1717
document.addEventListener("click", this.handleDocumentClick)
18+
this.wasMobile = this.isMobile()
1819

1920
if (!this.hasLayoutTarget || !this.hasSidebarTarget) {
2021
return
@@ -86,8 +87,12 @@ export default class extends Controller {
8687
}
8788

8889
handleWindowResize() {
89-
if (this.isMobile()) {
90+
const isMobile = this.isMobile()
91+
if (this.wasMobile && !isMobile) {
9092
this.closeMobile()
93+
}
94+
this.wasMobile = isMobile
95+
if (isMobile) {
9196
return
9297
}
9398

0 commit comments

Comments
 (0)