aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/components/PublicPageMenu/PublicPageMenuCustomEntry.vue
blob: f3c57a12042472728734151a4f606b000f06408c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!--
 - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 - SPDX-License-Identifier: AGPL-3.0-or-later
 -->
<template>
	<!-- eslint-disable-next-line vue/no-v-html -->
	<li ref="listItem" :role="itemRole" v-html="html" />
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'

defineProps<{
	id: string
	html: string
}>()

const listItem = ref<HTMLLIElement>()
const itemRole = ref('presentation')

onMounted(() => {
	// check for proper roles
	const menuitem = listItem.value?.querySelector('[role="menuitem"]')
	if (menuitem) {
		return
	}
	// check if a button is available
	const button = listItem.value?.querySelector('button') ?? listItem.value?.querySelector('a')
	if (button) {
		button.role = 'menuitem'
	} else {
		// if nothing is available set role on `<li>`
		itemRole.value = 'menuitem'
	}
})
</script>