Skip to content

Commit 98a6482

Browse files
committed
fix: don't close sidebar when clicking outside
Fixes #2510 This logic was introduced in #194 and further discussed in #2523. The app-navigation is now closing when clicking in content-area if a user uses a mobile device. The app-sidebar doesn't close when clicking inside the app-navigation or content-area anymore, similar to how the Calendar app handles it. Signed-off-by: Jakob Linskeseder <jakob@linskeseder.com>
1 parent e07a1a0 commit 98a6482

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/App.vue

+14-9
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2121

2222
<template>
2323
<NcContent app-name="tasks">
24-
<AppNavigation @click="closeAppSidebar($event)" />
24+
<AppNavigation />
2525

26-
<NcAppContent @click="closeAppSidebar($event)">
26+
<NcAppContent @click="closeAppNavigation">
2727
<RouterView />
2828
</NcAppContent>
2929

@@ -41,6 +41,7 @@ import NcAppContent from '@nextcloud/vue/components/NcAppContent'
4141
import NcContent from '@nextcloud/vue/components/NcContent'
4242

4343
import { mapGetters } from 'vuex'
44+
import { useIsMobile } from '@nextcloud/vue'
4445

4546
export default {
4647
name: 'App',
@@ -50,6 +51,12 @@ export default {
5051
NcContent,
5152
},
5253
inject: ['$OCA'],
54+
setup() {
55+
const isMobile = useIsMobile()
56+
return {
57+
isMobile,
58+
}
59+
},
5360
data() {
5461
return {
5562
searchString: '',
@@ -102,7 +109,7 @@ export default {
102109
* Fetch the tasks of each calendar
103110
*/
104111
fetchTasks() {
105-
// wait for all calendars to have fetch their tasks
112+
// wait for all calendars to have fetched their tasks
106113
Promise.all(this.calendars.map(calendar =>
107114
this.$store.dispatch('getTasksFromCalendar', { calendar, completed: false, related: null }),
108115
)).then(() => {
@@ -111,13 +118,11 @@ export default {
111118
},
112119

113120
/**
114-
* Close the details view
115-
*
116-
* @param {object} $event the event
121+
* Close the app navigation on mobile devices
117122
*/
118-
closeAppSidebar($event) {
119-
if (!($event.target.closest('.reactive') || $event.target.classList.contains('reactive')) && this.$route.params.taskId) {
120-
emit('tasks:close-appsidebar')
123+
closeAppNavigation() {
124+
if (this.isMobile) {
125+
emit('toggle-navigation', { open: false })
121126
}
122127
},
123128
filterProxy({ query }) {

0 commit comments

Comments
 (0)