Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@
if description.canUpdate(viewController: currentViewController) {
description.update(viewController: currentViewController)
} else {
if isViewLoaded {
currentViewController.willMove(toParent: nil)
currentViewController.view.removeFromSuperview()
currentViewController.removeFromParent()
}
currentViewController.willMove(toParent: nil)
currentViewController.viewIfLoaded?.removeFromSuperview()
currentViewController.removeFromParent()

currentViewController = description.buildViewController()

addChild(currentViewController)

if isViewLoaded {
addChild(currentViewController)
view.addSubview(currentViewController.view)
currentViewController.view.frame = view.bounds
currentViewController.didMove(toParent: self)
view.addSubview(currentViewController.view)
updatePreferredContentSizeIfNeeded()
}

currentViewController.didMove(toParent: self)
}
}

Expand Down
3 changes: 2 additions & 1 deletion WorkflowUI/Tests/DescribedViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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

}

func test_update_toIncompatibleDescription_afterViewLoads() {
Expand Down