KEMBAR78
refactor!: update popover overlay to use native popover by web-padawan · Pull Request #9785 · vaadin/web-components · GitHub
Skip to content

Conversation

@web-padawan
Copy link
Member

@web-padawan web-padawan commented Jul 21, 2025

Description

Fixes #9713

This changes the vaadin-popover to render content to itself. We can therefore consider deprecating renderer property and Lit directive and possibly update Flow counterpart to just use regular slotted content.

Note: snapshot tests for this component are missing, I'll add them in a follow-up PR.

Type of change

  • Breaking change

@web-padawan web-padawan force-pushed the refactor/popover-native-popover branch from 1580e0d to c5e6551 Compare July 21, 2025 13:15

root.innerHTML = `
<button>I have a popover</button>
<vaadin-popover>
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a nested popover to verify that dragging dialog while popover is opened doesn't hide popover overlay below the dialog one (which was originally reported at #8521).


const button = document.createElement('vaadin-button');
button.textContent = 'Apply';
const nested = document.createElement('vaadin-popover');
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a nested popover to make it easier to test different combination of triggers.

if (target) {
const parent = getClosestOverlay(target);
if (parent) {
setNestedOverlay(parent, opened ? this : null);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is no longer needed and I'll create a separate PR for removing setNestedOverlay helper altogether.
Calling bringToFront() for dialog when it has a popover open won't do anything since #9773.

@web-padawan web-padawan force-pushed the refactor/popover-native-popover branch from c5e6551 to f4a0321 Compare July 21, 2025 13:18
return;
}

// Copy custom properties from the owner
Copy link
Member Author

Choose a reason for hiding this comment

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

This is no longer needed as offset custom CSS properties will inherit to the overlay via cascade.

});
});

describe('bring to front', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Corresponding logic related to setNestedOverlay() was removed as no longer needed.

});
});

describe('modeless dialog', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

These tests don't make sense anymore: even if bringToFront() sets higher z-index on the overlay, the popover will still be shown on top of it because it's using popover, and the dialog currently does not.

I'll create a separate issue to add a new logic for bringing nested overlays to front and then re-add ITs.

return;
}

if ((this.__hasTrigger('focus') && this.__mouseDownInside) || this._overlayElement.contains(event.relatedTarget)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this._overlayElement.contains with this.contains here and elsewhere which seems correct: in case of moving focus by the browser Tab logic, the relatedTarget is vaadin-popover itself.

@web-padawan web-padawan marked this pull request as ready for review July 21, 2025 13:41

/**
* String used to label the overlay to screen reader users.
* String used to label the popover to screen reader users.
Copy link
Member Author

@web-padawan web-padawan Jul 21, 2025

Choose a reason for hiding this comment

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

We could probably deprecate accessibleName and accessibleNameRef or even remove them in favor of regular aria-label and aria-labelledby, respectively (and remove overrides from the Flow counterpart).


// If no user ID is provided, set generated ID
if (!this.id) {
this.id = this.__generatedId;
Copy link
Member Author

Choose a reason for hiding this comment

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

We could also add a mutation observer that would check if the user ID is removed and then set a generated one. Not sure if that's a common case, maybe we should create a follow-up issue and do it separately.

@web-padawan web-padawan requested a review from sissbruecker July 21, 2025 13:57
@web-padawan web-padawan force-pushed the refactor/popover-native-popover branch 2 times, most recently from e00cbf0 to d1bd34f Compare July 22, 2025 07:59
@web-padawan web-padawan force-pushed the refactor/popover-native-popover branch from 3ffd864 to 5d87b70 Compare July 22, 2025 08:58

const popoverOverlay = css`
:host {
--_default-offset: 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

Aligned the custom CSS property name with the one used in base styles.

@web-padawan web-padawan requested a review from sissbruecker July 22, 2025 09:08
web-padawan and others added 2 commits July 22, 2025 12:28
Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
@sonarqubecloud
Copy link

@web-padawan web-padawan merged commit 5458f76 into main Jul 22, 2025
10 checks passed
@web-padawan web-padawan deleted the refactor/popover-native-popover branch July 22, 2025 10:10
@vaadin-bot
Copy link
Collaborator

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

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.

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

3 participants