-
Notifications
You must be signed in to change notification settings - Fork 83
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not close popover when it is just moved in DOM #8208
Conversation
Quality Gate passedIssues Measures |
// Automatically close popover when it is removed from DOM | ||
// Avoid closing if the popover is just moved in the DOM | ||
queueMicrotask(() => { | ||
if (!this.isConnected) { | ||
this._openedStateController.close(true); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is adopted from notification:
web-components/packages/notification/src/vaadin-notification-mixin.js
Lines 255 to 259 in 003bbb3
queueMicrotask(() => { | |
if (!this.isConnected) { | |
this.opened = false; | |
} | |
}); |
Other components such as dialog also have logic for restoring the opened state, but I'm not sure if this is necessary at this point.
Co-authored-by: Sascha Ißbrücker <[email protected]>
Currently a popover is immediately closed when it is disconnected from the DOM. That can be an issue in a Flow dialog when the popover is opened right away after adding it to the dialog. Here the element is first added as a child of the dialog, then opened, and afterwards moved to the dialog overlay by the renderer function. The last step causes the popover to close again.
This fixes the issue by delaying closing and checking if the element has been added to the DOM again. This is similar to what we are doing in other components such as dialog or notification.
Fixes vaadin/flow-components#6840