Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/NcAppNavigationItem/NcAppNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ Just set the `pinned` prop.
</template>

<script>
import { emit } from '@nextcloud/event-bus'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import Undo from 'vue-material-design-icons/Undo.vue'
import NcAppNavigationIconCollapsible from './NcAppNavigationIconCollapsible.vue'
Expand Down Expand Up @@ -744,6 +745,10 @@ export default {
if (routerLinkHref) {
navigate?.(event)
event.preventDefault()
// On mobile, close app-navigation when navigating so it doesn't overlay content
if (this.isMobile) {
emit('toggle-navigation', { open: false })
}
}
},

Expand Down
38 changes: 38 additions & 0 deletions tests/unit/components/NcAppNavigation/NcAppNavigationItem.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { mount } from '@vue/test-utils'
import { describe, expect, it, vi } from 'vitest'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to adapt this for jest on this branch @jancborchardt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @jancborchardt

could your adjust this PR so we can align features on both branches?

import NcAppNavigationItem from '../../../../src/components/NcAppNavigationItem/NcAppNavigationItem.vue'
import { resizeWindowWidth } from '../../testing-utils.ts'

describe('NcAppNavigationItem.vue', () => {
describe('router-link navigation on mobile', () => {
it('closes the app navigation after navigating', async () => {
await resizeWindowWidth(500)
const wrapper = mount(NcAppNavigationItem, { props: { name: 'Item' } })
const handler = vi.fn()
subscribe('toggle-navigation', handler)

wrapper.vm.onClick(new MouseEvent('click'), vi.fn(), '/href')

expect(handler).toHaveBeenCalledWith({ open: false })
unsubscribe('toggle-navigation', handler)
})

it('does not close the app navigation on desktop', async () => {
await resizeWindowWidth(1024)
const wrapper = mount(NcAppNavigationItem, { props: { name: 'Item' } })
const handler = vi.fn()
subscribe('toggle-navigation', handler)

wrapper.vm.onClick(new MouseEvent('click'), vi.fn(), '/href')

expect(handler).not.toHaveBeenCalled()
unsubscribe('toggle-navigation', handler)
})
})
})
Loading