ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.1k stars 13.5k forks source link

bug: Input auto-scroll fails in some cases #26803

Closed vojto closed 1 year ago

vojto commented 1 year ago

Prerequisites

Ionic Framework Version

Current Behavior

1. Input in the middle of a 100%+ tall screen:

https://user-images.githubusercontent.com/50943/219325201-fa611fd9-4908-4ea3-90c7-8800f7228d83.mp4

Focusing works well, blurring doesn't change the position


2. Input at the end of a 80% tall screen

https://user-images.githubusercontent.com/50943/219326275-88dd99ce-7d23-4777-acda-a8d001eed022.mp4

Focusing doesn't work at all, blurring jumps back into previous position (instead of smooth scroll)


3. Input at the end of 100%+ tall screen

https://user-images.githubusercontent.com/50943/219327180-774cfde1-e970-4ee6-81b4-dc1a42364e36.MP4

Focusing works well, blurring jumps back to position (instead of smooth scroll)

Expected Behavior

All animations should work just like the system animation, shown here:

https://user-images.githubusercontent.com/50943/219069658-c07f6330-1fc2-499f-8753-f4c36ea50887.mp4


Steps to Reproduce

Create a simple page with a few spacer elements, and input, as shown here: https://github.com/vojto/ionic-input-repro/blob/main/components/AppShell.jsx#L39-L63

Code Reproduction URL

https://github.com/vojto/ionic-input-repro

Ionic Info

ionic info doesn't seem to be updated for v7 beta?

➜  nextjs-tailwind-ionic-capacitor-starter git:(main) ✗ npx ionic info
[WARN] You are not in an Ionic project directory. Project context may be missing.

Additional Information

No response

liamdebeasi commented 1 year ago

Thanks for testing Ionic 7! I can reproduce this behavior. Can you give this dev build a shot, and let me know if it resolves the issue?

npm install @ionic/core@7.0.0-dev.11676564756.14eccca7 @ionic/react@7.0.0-dev.11676564756.14eccca7 @ionic/react-router@7.0.0-dev.11676564756.14eccca7
vojto commented 1 year ago

That's much better.

It still doesn't animate on blur, just jumps back into position. I'm assuming that would be too complicated to implement?

liamdebeasi commented 1 year ago

When the input is blurred we removed the padding-bottom on the .inner-scroll element which does not have a transition by default. You could try adding a transition, but it might look a bit janky:

ion-content::part(scroll) {
  transition: padding-bottom 1s ease-in-out;
}
liamdebeasi commented 1 year ago

Thanks for the issue. This has been resolved via https://github.com/ionic-team/ionic-framework/pull/26810, and a fix will be available in an upcoming release of Ionic Framework. I focused on getting parity with what happens in Ionic v6, so there is no padding transition on blur. However, you can use the code snippet above if you would like to test the transition in your app. Let me know if you have any questions.

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.