Skip to content

Dialog: aria-labelledby is wrongly assigned, when there is no header property, but custom header slot #8547

@hedgehog9898

Description

@hedgehog9898

Describe the bug

When using the Dialog component with a custom header slot and without providing the header prop, the component still generates and assigns an aria-labelledby attribute with an internal ID. However, this ID is not applied to any actual DOM element in the custom header. As a result, the attribute references a non-existent element, which breaks accessibility.

Pull Request Link

#8549

Reproducer

https://primevue.org/dialog/#headless

Environment

Nuxt.js (4.2.2)

Vue version

3.5.26

PrimeVue version

4.5.4

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

  1. Go to https://primevue.org/dialog/#headless
  2. Open dialog
  3. On the child element of root p-dialog-mask there is div "p-dialog p-component !border-0 !bg-transparent" with assigned aria-labelledby attribute, but there is no possibility to attach this id to customer header element, which leading to breaking accessibility and aria-labelledby attribute references to non-exist header's id.

Expected behavior

Maybe pass into the slot parameters the generated id like this

<PrimeDialog
    v-model:visible="visible"
    :closable="false"
    :draggable="false"
    class="car-edit-dialog tablet:min-w-167.5 mx-6"
    data-pw="car-edit-dialog"
    modal
  >
    <template #header={ headerId }>
      <div class="flex items-center justify-between w-full relative">
        <h2 :id="headerId" class="ods-typography-subtitle">{{ $t('car-edit-dialog.title') }}</h2>
      </div>
    </template>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possible

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions