Skip to content

Commit bfc4c43

Browse files
committed
Fix issue where state transition did not end when not being animated
1 parent 5f9048d commit bfc4c43

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/StateViewController.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ fileprivate extension StateViewController {
506506
return false
507507
}
508508

509+
// We may not have made any changes to content view controllers, even though we have changed the state.
510+
// Therefore, we must be prepare to end the state transition immediately.
511+
defer {
512+
endStateTransitionIfNeeded(animated: animated)
513+
}
514+
509515
// If we're transitioning between states, we need to abort and wait for the current state
510516
// transition to finish.
511517
guard isTransitioningBetweenStates == false else {
@@ -517,11 +523,6 @@ fileprivate extension StateViewController {
517523
willTransition(to: state, animated: animated)
518524
dispatchStateEvent(.willTransitionTo(nextState: state, animated: animated))
519525

520-
// We may not have made any changes to content view controllers, even though we have changed the state.
521-
// Therefore, we must be prepare to end the state transition immediately.
522-
defer {
523-
endStateTransitionIfNeeded(animated: animated)
524-
}
525526

526527
// Note that we're transitioning from a state
527528
transitioningFromState = state

0 commit comments

Comments
 (0)