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

Conversation

@sissbruecker
Copy link
Contributor

Description

Fixes #9732

Type of change

  • Breaking change

Comment on lines +436 to +452
/** @protected */
updated(props) {
super.updated(props);

// When using dialog mode, hide elements not slotted into the dialog from accessibility tree
if (
props.has('_grid') ||
props.has('_newButton') ||
props.has('editorOpened') ||
props.has('editorPosition') ||
props.has('_fullscreen')
) {
const hide = this.editorOpened && this._dialogMode;
this.__hideElement(this._grid, hide);
this.__hideElement(this._newButton, hide);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The aria-hidden logic needs some customization, as we need to hide all elements that are not in the dialog. So the solution now is:

  • Use CRUD itself as modal root
  • Then add this custom logic to also hide elements that are not slotted into the dialog when it is opened

Comment on lines +516 to +519
// Wait to set label until header node has updated (observer seems to run after this one)
setTimeout(() => {
this.__dialogAriaLabel = this._headerNode.textContent.trim();
});
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 could be better, but I couldn't find a simple solution.

Updating the label here is easiest as it also handles text content of custom header nodes.The timeout could be avoided if all observer logic were moved into updated. Then we could control the order of updates, so that the default header node would be updated before running this opened update logic. But that would also require several changes.

</div>
<slot name="form"></slot>
</div>
${!this._dialogMode
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Considered using cache as suggested, but I think switching between modes shouldn't happen as often (or at all for a single user), so I figure it's not necessary.

Comment on lines -14 to -22
afterEach(async () => {
// Wait until the crud dialog overlay is closed
let overlay;
while ((overlay = document.querySelector('body > vaadin-crud-dialog-overlay'))) {
// Press esc to close the dialog
overlay.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
await aTimeout(1);
}
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't seem to be necessary anymore?

['default', 'custom'].forEach((type) => {
describe(`${type} form`, () => {
let dialog, form, btnCancel, overlay;
describe('editor mode', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced the previous teleporting logic tests with this suite that verifies that either the inline editor or dialog are rendered with respective slots.

@sissbruecker sissbruecker marked this pull request as ready for review July 23, 2025 08:03
@sissbruecker sissbruecker requested a review from web-padawan July 23, 2025 08:03
@sissbruecker sissbruecker requested a review from web-padawan July 23, 2025 10:25
@sonarqubecloud
Copy link

@sissbruecker sissbruecker merged commit 8ff92f5 into main Jul 23, 2025
10 checks passed
@sissbruecker sissbruecker deleted the refactor/crud-editor-native-popover branch July 23, 2025 13:37
@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.

[crud] Update editor dialog to use popover element for the default / fullscreen editor

3 participants