diff --git a/src/components/NcAppNavigationCaption/NcAppNavigationCaption.vue b/src/components/NcAppNavigationCaption/NcAppNavigationCaption.vue
index d614963063..3df6740670 100644
--- a/src/components/NcAppNavigationCaption/NcAppNavigationCaption.vue
+++ b/src/components/NcAppNavigationCaption/NcAppNavigationCaption.vue
@@ -1,4 +1,6 @@
+### Basic usage
+
```vue
@@ -95,6 +97,23 @@
```
+### Element used as a heading
+```vue
+
+
+
+
+
+
+
+
+
+
+
+```
+
@@ -102,7 +121,9 @@
class="app-navigation-caption"
:class="{ 'app-navigation-caption--heading': isHeading }">
-
+
{{ name }}
@@ -139,6 +160,15 @@ export default {
required: true,
},
+ /**
+ * `id` to set on the inner caption
+ * Can be used for connecting the `NcActionCaption` with `NcActionList` using `aria-labelledby`.
+ */
+ headingId: {
+ type: String,
+ default: null,
+ },
+
/**
* Enable when used as a heading
* e.g. Before NcAppNavigationList
diff --git a/tests/unit/components/NcAppNavigation/NcAppNavigation.spec.js b/tests/unit/components/NcAppNavigation/NcAppNavigation.spec.js
index 0c3d103465..34023842b7 100644
--- a/tests/unit/components/NcAppNavigation/NcAppNavigation.spec.js
+++ b/tests/unit/components/NcAppNavigation/NcAppNavigation.spec.js
@@ -19,7 +19,7 @@
* along with this program. If not, see .
*
*/
-import { describe, it, expect, afterEach } from '@jest/globals'
+import { describe, it, expect } from '@jest/globals'
import { mount } from '@vue/test-utils'
import { emit } from '@nextcloud/event-bus'
import { nextTick } from 'vue'
diff --git a/tests/unit/components/NcAppNavigation/NcAppNavigationCaption.spec.ts b/tests/unit/components/NcAppNavigation/NcAppNavigationCaption.spec.ts
index b15151a216..e829b4e0d9 100644
--- a/tests/unit/components/NcAppNavigation/NcAppNavigationCaption.spec.ts
+++ b/tests/unit/components/NcAppNavigation/NcAppNavigationCaption.spec.ts
@@ -1,4 +1,4 @@
-import { describe, expect } from '@jest/globals'
+import { describe, expect, test } from '@jest/globals'
import { shallowMount } from '@vue/test-utils'
import NcAppNavigationCaption from '../../../../src/components/NcAppNavigationCaption/NcAppNavigationCaption.vue'
@@ -22,6 +22,18 @@ describe('NcAppNavigationCaption.vue', () => {
expect(wrapper.findComponent({ name: 'NcActions' }).attributes('forcemenu')).toBe('true')
})
+ test('can set id on the caption', async () => {
+ const wrapper = shallowMount(NcAppNavigationCaption, {
+ propsData: {
+ name: 'The name',
+ isHeading: true,
+ headingId: 'my-heading-id',
+ },
+ })
+
+ expect(wrapper.find('h2').attributes('id')).toBe('my-heading-id')
+ })
+
test('component is a list entry by default', async () => {
const wrapper = shallowMount(NcAppNavigationCaption, {
propsData: {