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

fix(transition): ios transition works on devices without IO support #21339

Merged
merged 4 commits into from
May 27, 2020
Merged

fix(transition): ios transition works on devices without IO support #21339

merged 4 commits into from
May 27, 2020

Conversation

DavidStrausz
Copy link
Contributor

@DavidStrausz DavidStrausz commented May 19, 2020

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

The following error is thrown on every page transition if using collapsible headers on a device without IntersectionObserver support:

TypeError: null is not an object (evaluating 'clonedTitleEl.innerText = largeTitleEl.innerText')

Issue Number: fixes #21221

What is the new behavior?

The part of the the page transition where the cloned element would be needed is skipped in case the IO API is not available.

Does this introduce a breaking change?

  • Yes
  • No

@ionitron-bot ionitron-bot bot added the package: core @ionic/core package label May 19, 2020
Copy link
Contributor

@liamdebeasi liamdebeasi 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 the PR! I am not sure this is the best approach to fixing this bug. If IntersectionObserver is not supported, the collapsable header should not even be activated. In that case, a check here should not even be necessary.

Maybe we can have some logic here that checks for API support? https://github.com/ionic-team/ionic/blob/master/core/src/components/header/header.tsx#L145

Without intersection observer support, the collapsable header is pretty much useless so I am not sure it's even worth it to have the class applied.

@DavidStrausz
Copy link
Contributor Author

@liamdebeasi Hm I'm not sure we're 100% talking about the same thing here. I agree it's useless to setup the collapse animation without IO support. The root problem is that the animation logic is completly separated from the component (in the iOS transition), and it is accessing the cloned title and back button elements for example:

here:
https://github.com/ionic-team/ionic/blob/6b159a0e913169ded8e829ee37668bb0e694ce93/core/src/utils/transition/ios.transition.ts#L188

or here:
https://github.com/ionic-team/ionic/blob/6b159a0e913169ded8e829ee37668bb0e694ce93/core/src/utils/transition/ios.transition.ts#L131

These are only created if the collapsible header is setup - but as it is not setup anymore (this was fixed by you in #21222) this leads to a TypeError.

At first I wanted to skip creating the large title animation at all, but the return values are used further down the pipe to determine if we're animating forward or backward:

https://github.com/ionic-team/ionic/blob/6b159a0e913169ded8e829ee37668bb0e694ce93/core/src/utils/transition/ios.transition.ts#L303

https://github.com/ionic-team/ionic/blob/6b159a0e913169ded8e829ee37668bb0e694ce93/core/src/utils/transition/ios.transition.ts#L524

So yeah, I it's not the prettiest fix, but it does the job.

@liamdebeasi
Copy link
Contributor

Oh hmm... Maybe it should still create the cloned title regardless of IO support: https://github.com/ionic-team/ionic/blob/master/core/src/components/header/header.tsx#L129-L132.

The cloned elements are really more for the large title transition than it is for the collapsable header. If we did that, then the check in the iOS transition file should not be necessary.

@DavidStrausz
Copy link
Contributor Author

@liamdebeasi Yeah sure, that should work as well, I'll move the cloning parts before the early exit and revert the check in the transition tomorrow as soon as I'm back at my dev machine! Or feel free to close my PR if you want to do it yourself :)

@liamdebeasi
Copy link
Contributor

I'll stick with this PR -- will take another look when the changes are made, but I think we should be good to merge after.

@DavidStrausz
Copy link
Contributor Author

Great! Thanks for the feedback so far, I‘ll let you know when I‘m done!

@DavidStrausz
Copy link
Contributor Author

@liamdebeasi This is ready for review again :)

@liamdebeasi liamdebeasi merged commit 2dac12c into ionic-team:master May 27, 2020
@liamdebeasi
Copy link
Contributor

Merged. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: gracefully fail if IntersectionObserver is not available
2 participants