Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(NcDialog): Label dialog nav #4928

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/components/NcDialog/NcDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ export default {
@close="handleClosed"
@update:show="handleClosing">
<!-- The dialog name / header -->
<h2 class="dialog__name" v-text="name" />
<h2 :id="navigationId" class="dialog__name" v-text="name" />
<div class="dialog" :class="dialogClasses">
<div ref="wrapper" :class="['dialog__wrapper', { 'dialog__wrapper--collapsed': isNavigationCollapsed }]">
<!-- When the navigation is collapsed (too small dialog) it is displayed above the main content, otherwise on the inline start -->
<nav v-if="hasNavigation" class="dialog__navigation" :class="navigationClasses">
<nav v-if="hasNavigation"
class="dialog__navigation"
:class="navigationClasses"
:aria-labelledby="navigationId">
<slot name="navigation" :is-collapsed="isNavigationCollapsed" />
</nav>
<!-- Main dialog content -->
Expand Down Expand Up @@ -132,6 +135,8 @@ import { computed, defineComponent, ref } from 'vue'
import NcModal from '../NcModal/index.js'
import NcDialogButton from '../NcDialogButton/index.js'

import GenRandomId from '../../utils/GenRandomId.js'

export default defineComponent({
name: 'NcDialog',

Expand Down Expand Up @@ -287,6 +292,11 @@ export default defineComponent({
*/
const hasNavigation = computed(() => slots?.navigation !== undefined)

/**
* The unique id of the nav element
*/
const navigationId = ref(GenRandomId())
Pytal marked this conversation as resolved.
Show resolved Hide resolved

/**
* If the underlaying modal is shown
*/
Expand Down Expand Up @@ -345,6 +355,7 @@ export default defineComponent({
handleClosing,
handleClosed,
hasNavigation,
navigationId,
isNavigationCollapsed,
modalProps,
wrapper,
Expand Down