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 cleanup for overlay2 component #6753

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

maxpolski
Copy link
Contributor

Fixes #6752

Checklist

  • [x ] Includes tests
  • Update documentation

Changes proposed in this pull request:

TLDR isOpen is almost never true inside the useEffect callback.

Removed the if statement which was using an outdated state variable inside of the useEffect and prevented from cleanup on component unmount, which could happen if user forced the modal to close (e.g. navigating from the parent view). In this case useEffect doesn't have any dependencies and only returns a callback that will run on the component unmount, but since the useEffect doesn't have any dependencies, body of the useEffect won't be re-evaluated on the subsequent component re-renders. So the callback function will only keep in its scope the initial component's values (isOpen and overlayWillClose in this case). It might be okay to keep the initial value of the overlayWillClose function, but if the component was initialized with isOpen === false then the overlayWillClose function will never be called.

Reviewers should focus on:

Double checking for potential side-effects of the if statement removal

@palantirtech
Copy link
Member

Thanks for your interest in palantir/blueprint, @maxpolski! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@changelog-app
Copy link

changelog-app bot commented Mar 29, 2024

Generate changelog in packages/core/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

fix cleanup for overlay2 component

Check the box to generate changelog(s)

  • Generate changelog entry

Copy link
Contributor

@ericjeney ericjeney left a comment

Choose a reason for hiding this comment

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

Thank you for fixing, and for adding the test!

Your explanation makes sense, and running this cleanup code on every unmount mirrors the behavior of the original overlay component better as well:

public componentWillUnmount() {
this.overlayWillClose();
}

@ericjeney ericjeney merged commit f2c86bc into palantir:develop Apr 19, 2024
12 of 14 checks passed
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 component does not cleanup the overlay's side effects on redirects without onClose
3 participants