Skip to content

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.

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


// 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