Skip to content

Commit 8f23ad2

Browse files
gkokorelstar
authored andcommitted
fix sidebar behaviour in mobile mode
1 parent 130491c commit 8f23ad2

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

src/App.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import AppSettings from './components/AppSettings'
3636
import NavigationList from './components/NavigationList'
3737
import NotesService from './NotesService'
3838
import store from './store'
39+
import { openNavbar } from './nextcloud'
3940
4041
export default {
4142
name: 'App',
@@ -164,10 +165,8 @@ export default {
164165
165166
onSearch(query) {
166167
this.filter.search = query
167-
// TODO move the following from jQuery to plain JS
168-
if ($('#app-navigation-toggle').css('display') !== 'none' && !$('body').hasClass('snapjs-left')) {
169-
$('#app-navigation-toggle').click()
170-
}
168+
169+
openNavbar()
171170
},
172171
173172
onResetSearch() {
@@ -192,8 +191,11 @@ export default {
192191
193192
onSelectCategory(category) {
194193
this.filter.category = category
195-
// TODO move the following from jQuery to plain JS
196-
$('#app-navigation > ul').animate({ scrollTop: 0 }, 'fast')
194+
195+
const appNavigation = document.querySelector('#app-navigation > ul')
196+
if (appNavigation) {
197+
appNavigation.scrollTop = 0
198+
}
197199
},
198200
199201
onClose(event) {

src/components/Note.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import TheEditor from './EditorEasyMDE'
6161
import ThePreview from './EditorMarkdownIt'
6262
import NotesService from '../NotesService'
6363
import store from '../store'
64+
import { closeNavbar } from '../nextcloud'
6465
6566
export default {
6667
name: 'Note',
@@ -130,6 +131,9 @@ export default {
130131
methods: {
131132
fetchData() {
132133
store.commit('setSidebarOpen', false)
134+
135+
closeNavbar()
136+
133137
this.onUpdateTitle(this.title)
134138
this.loading = true
135139
this.preview = false

src/nextcloud.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* global nextcloud helpers
3+
*/
4+
5+
const closeNavbar = () => {
6+
const navigationToggle = document.getElementById('app-navigation-toggle')
7+
const navOpen = document.body.classList.contains('nav-open')
8+
9+
if (
10+
navigationToggle
11+
&& navigationToggle.style.display !== 'none'
12+
&& navOpen
13+
) {
14+
navigationToggle.click()
15+
}
16+
}
17+
18+
const openNavbar = () => {
19+
const navigationToggle = document.getElementById('app-navigation-toggle')
20+
const navOpen = document.body.classList.contains('nav-open')
21+
22+
if (
23+
navigationToggle
24+
&& navigationToggle.style.display !== 'none'
25+
&& !navOpen
26+
) {
27+
navigationToggle.click()
28+
}
29+
}
30+
31+
export { closeNavbar, openNavbar }

0 commit comments

Comments
 (0)