Skip to content
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: only fire opened change events on state change #5111

Closed

Conversation

ugur-vaadin
Copy link
Contributor

@ugur-vaadin ugur-vaadin commented Jun 2, 2023

Description

As stated in a comment in the issue, a subdialog momentarily disconnects and reconnects when opened. This results in 2 extra opened-change events. The changes in those events are not actually reflected in the server-side opened state of the component. This PR prevents the event to be fired when there is no actual change in the state.

Fixes #5103

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/overview
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ugur-vaadin ugur-vaadin marked this pull request as ready for review June 2, 2023 09:06
@ugur-vaadin ugur-vaadin assigned sissbruecker and vursen and unassigned sissbruecker and vursen Jun 2, 2023
@sissbruecker
Copy link
Contributor

The root cause here is that the dialog WC toggles its opened state when it is disconnected / reconnected to the DOM as part of being moved to the parent dialog's overlay by the dialog renderer function. This is a result of the comment here: vaadin/web-components#3648 (comment), where we decided to avoid using a timeout to detect if the dialog stays disconnected.

In hindsight using a timeout might be better as we probably also want to avoid opened-changed events when just moving the dialog in the DOM. I've opened a PR (vaadin/web-components#5995) to fix the issue using a timeout, and will mark this as draft in the meantime. We can close this PR if we agree to use the timeout solution.

@sissbruecker sissbruecker marked this pull request as draft June 19, 2023 15:02
@sissbruecker
Copy link
Contributor

Closing in favor of vaadin/web-components#5995

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dialog opened from a Dialog fires OpenedChangeEvent multiple times
3 participants