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

Always remove child view controller from DescribedViewController #115

Merged
merged 2 commits into from
Jan 8, 2022

Conversation

kylebshr
Copy link
Contributor

@kylebshr kylebshr commented Jan 8, 2022

Fixes an issue where the child of a DescribedViewController wasn't removed even when the currentViewController was replaced. This issue was introduced in #108 - we started setting up the parent-child relationship in the init, but only remove the child if our view is loaded. In the case where an update happens before the view is loaded, that initial child is never removed.

The left-behind relationship and view was causing issues where (correct) assumptions about the view and view controller hierarchy were invalid, causing this crash: https://square.slack.com/archives/CTJ4UNLHF/p1641510705024100

Thanks @tyten and @kyleve for helping debug!

Checklist

  • Unit Tests
  • UI Tests
  • Snapshot Tests (iOS only)
  • I have made corresponding changes to the documentation

@CLAassistant
Copy link

CLAassistant commented Jan 8, 2022

CLA assistant check
All committers have signed the CLA.

XCTAssertEqual((describedViewController.currentViewController as? MessageViewController)?.message, "Test")
XCTAssertFalse(describedViewController.isViewLoaded)
XCTAssertFalse(describedViewController.currentViewController.isViewLoaded)
XCTAssertNil(describedViewController.currentViewController.parent)
XCTAssertEqual(describedViewController.currentViewController.parent, describedViewController)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We actually do want this child-parent relationship set up, which is also fixed

@@ -108,10 +108,11 @@

// Then
XCTAssertNotEqual(initialChildViewController, describedViewController.currentViewController)
XCTAssertNil(initialChildViewController.parent)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test validates the fix. It fails on main.

Copy link
Contributor

@dhavalshreyas dhavalshreyas 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!

@dhavalshreyas dhavalshreyas merged commit a804820 into square:main Jan 8, 2022
Copy link
Collaborator

@n8chur n8chur left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

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.

6 participants