KEMBAR78
refactor!: update dialog to use native popover by sissbruecker · Pull Request #9807 · vaadin/web-components · GitHub
Skip to content

Conversation

@sissbruecker
Copy link
Contributor

Description

Fixes #9727

Type of change

  • Breaking change

firstUpdated(props) {
super.firstUpdated(props);

this.role = 'dialog';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary anymore, as it's set by DialogBaseMixin

Comment on lines +106 to 118
if (!this.hasAttribute('role')) {
this.role = 'dialog';
}
}

/** @protected */
updated(props) {
super.updated(props);

if (props.has('overlayRole')) {
this.role = this.overlayRole || 'dialog';
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this so you can use role instead of overlayRole.

Comment on lines 161 to 176
/** @private */
__applyHeaderTitleAriaLabel() {
// If there is a header title and no aria-label,
// set the aria-label to the header title.
if (this.headerTitle && !this.ariaLabel) {
this.ariaLabel = this.headerTitle;
this.__useHeaderTitleAriaLabel = true;
}

// If there is no header title and the aria-label was set
// using a header title, remove the aria-label.
if (this.__useHeaderTitleAriaLabel && !this.headerTitle) {
this.ariaLabel = null;
this.__useHeaderTitleAriaLabel = false;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Likewise, this is supposed to allow using aria-label instead of headerTitle.

Put this into dialog itself, as DialogBaseMixin is used in CRUD where we need different logic and it doesn't have headerTitle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if this can be simplified. If updated doesn't include headerTitle if it's never set, then tracking the state wouldn't be necessary.

Copy link
Member

Choose a reason for hiding this comment

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

If updated doesn't include headerTitle if it's never set

Yes, I think that's the case.

Technically it's possible that ariaLabel is set, then headerTitle is set, and then ariaLabel gets removed - in theory, we probably should then set default ariaLabel based on headerTitle. But it's probably an edge case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simplified it for now. A practical case might be to use a different aria-label than the header title, but that seems unlikely.

await nextRender();
});

describe('aria-label', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just testing delegating the label to the overlay. Just setting aria-label on the dialog shouldn't require tests now, the combination with headerTitle is tested in header-footer.test.js.

@sissbruecker sissbruecker marked this pull request as ready for review July 28, 2025 07:48
@sissbruecker sissbruecker requested a review from web-padawan July 28, 2025 07:48
@sonarqubecloud
Copy link

@sissbruecker sissbruecker merged commit 1d99685 into main Jul 28, 2025
10 checks passed
@sissbruecker sissbruecker deleted the refactor/dialog-native-popover branch July 28, 2025 10:11
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 25.0.0-beta2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dialog] Update to use native popover for the overlay element

3 participants