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: restore overlay opened state when moving within the DOM #3648

Merged
merged 4 commits into from
Apr 11, 2022

Conversation

sissbruecker
Copy link
Contributor

@sissbruecker sissbruecker commented Apr 6, 2022

Description

Restores overlay opened state when disconnecting and then reconnecting the element, for example when moving the element in the DOM. Applies to vaadin-dialog and vaadin-login-overlay.

Fixes vaadin/flow-components#2979
Fixes vaadin/flow-components#2087
Fixes #2125

Type of change

  • Bugfix

@vursen
Copy link
Contributor

vursen commented Apr 7, 2022

Although I'm generally not very happy about solutions based on setTimeout, this case can probably be considered special as I don't think someone would rely on the synchronous closing of the dialog when it is disconnected. At least, I couldn't come up with a case where it might cause a problem. So looks good to me.

An alternative could be something like:

class Dialog {
  connectedCallback() {
    super.connectedCallback();

    if (this.__restoreOpened) {
      this.opened = true;
    }
  }

  disconnectedCallback() {
    super.disconnectedCallback();
    
    if (this.opened) {
      this.__restoreOpened = true;
      this.opened = false;
    }
  }
}

That would open / close the dialog synchronously but that solution is surely less laconic, compared to setTimeout.

@sissbruecker sissbruecker changed the title fix: prevent dialog from closing when moving within the DOM fix: restore overlay opened state when moving within the DOM Apr 11, 2022
@sissbruecker sissbruecker marked this pull request as ready for review April 11, 2022 09:05
@sissbruecker sissbruecker requested a review from vursen April 11, 2022 09:05
@sonarqubecloud
Copy link

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 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 23.1.0.alpha2 and is also targeting the upcoming stable 23.1.0 version.

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