Skip to content

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Jun 2, 2025

Description

The fix boils down to removing check whether changeRootIndex == controllers.count. It was introduced here:
#502.
It can be represented differently: changeRootIndex == controllers.lastIndex + 1 & if I get this correctly it checks whether
the modal change in question takes place at the top of view hierarchy,
with purpose of not animating non visible changes.

It does not take account the replace operation though. In case of
replace, the changeRootIndex == controllers.lastIndex.

Another aspect is that I believe this part of the check is not
necessary. If some modal view controller is being dismissed, all
view controllers above it will also endup dismissed.
Therefore, there is no scenario where this check would be useful.

Hence, this commit ends up removing the check.

Before & After

before after
bug-recording.mov
fix-recording.mov

Test code and steps to reproduce

I've enhanced TestModalNavigation with additional button that allows for modal replacement.

I've also tested TestModalNavigation to make sure other flows keep working.
I've also tested #502 - setting animation: 'none' keeps working for dismissed modals.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

kkafar added 2 commits June 2, 2025 11:27
The fix boils down to removing check whether `changeRootIndex ==
controllers.count`. It was introduced here:
#502.
It can be represented differently: `changeRootIndex ==
controllers.lastIndex + 1` & if I get this correctly it checks whether
the modal change in question takes place at the top of view hierarchy,
with purpose of not animating non visible changes.

It does not take account the replace operation though. In case of
replace, the `changeRootIndex == controllers.lastIndex`.

Another aspect is that I believe this part of the check is not
necessary. If some modal view controller is being dismissed, **all**
view controllers above it will also endup dismissed.
Therefore, there is no scenario where this check would be useful.

Hence, this commit ends up removing the check.
@kkafar kkafar changed the title fix(iOS): lack of animation on modal replace fix(iOS): lack of animation on modal replacement Jun 2, 2025
@kkafar kkafar requested review from kligarski and maciekstosio June 2, 2025 11:35
@kkafar
Copy link
Member Author

kkafar commented Jun 2, 2025

@hirbod you might wanna check this one out in context of the issue we've talked about.
I don't think this is it, but there is a slight change it is.

@hirbod
Copy link
Contributor

hirbod commented Jun 2, 2025

Hi @kkafar, thanks for the tag. I’ll pull the PR and test it. I do think this issue is unrelated though and probably a different one. That said, I love this PR anyway, it makes replacing a modal screen way easier and removes the need for setTimeout and such.

@kkafar kkafar merged commit 0564d43 into main Jun 2, 2025
6 of 7 checks passed
@kkafar kkafar deleted the @kkafar/modal-replace-animation branch June 2, 2025 14:41
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.

3 participants