unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.77k stars 706 forks source link

[Android][iOS] Changing Margin from InputPan (Showing/Hiding) handlers doesn't update the layout #14010

Open Soap-141 opened 11 months ago

Soap-141 commented 11 months ago

Current behavior

We noticed an issue with the keyboard in our chat application on Android and sometimes iOS that I can't reproduce unfortunately. Basically at first we were using the Uno.Toolkit.UI SafeArea control (it had the same issue) but since we were using it in a page containing a ListView we knew it was a bad idea since the control basically wraps its content in a ScrollViewer. So we made a draft for a custom behavior to add margin when the keyboard is hiding our container and we noticed that on mobile, when we have more then like two item in our list, the layout is not built correctly most of the time it only works the first time and then it does not.

The issue in the sample I made is very similar to our chat application but slightly different because in this one, the TextBox goes up but not chat while in our real application it is a mix of both.

This is an issue using Uno.Extensions and Chinook frameworks (Feeds & DataLoader).

Also, the keyboard behavior is not supported out of the box in the Uno chat sample.

Animation_124

Expected behavior

It should behave like iOS when it's working. We did encounter the issue on iOS but I'm not able to reproduce it. Animation_125

How to reproduce it (as minimally and precisely as possible)

  1. Download ChatUI.zip or use Uno.Samples.
  2. Start the application on Android.
  3. Click on the TextBox.
  4. Notice the layout behavior when the keyboard is open.

Workaround

Nothing that I know off. I tried to rebuild the layout of the Grid using InvalidateMeasure and all that stuff but it did not work.

Works on UWP/WinUI

None

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia, Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

Latest Uno 5 preview and Latest Uno 4.10 stable release.

Affected platforms

Android, iOS

IDE

Visual Studio 2022

IDE version

17.7.5

Relevant plugins

N/A

Anything else we need to know?

Keyboard management sample code is in InputPaneExtensions.PanIntoView.cs.

Soap-141 commented 11 months ago

@jeromelaban it might be related to https://github.com/unoplatform/uno/issues/13351

MartinZikmund commented 10 months ago

As a workaround you can schedule the change asynchronously on the dispatcher, that should work

Soap-141 commented 10 months ago

@MartinZikmund I will try thanks!

Soap-141 commented 10 months ago

@MartinZikmund Not working in the dispatcher.

kazo0 commented 10 months ago

@Soap-141 I noticed that we are using AdjustNothing at this line

Can you try using AdjustResize and see what happens?

Soap-141 commented 9 months ago

@kazo0 It will semi fix Android because it will only push up to the text and not the textbox, I assume that Uno want to manage that on it's on so no conflict? Also this part won't fix it for iOS.

ajpinedam commented 9 months ago

I tested this with one of the latest stable Uno Platform (5.0.41), and I could not reproduce it anymore.

@Soap-141 can you give it a try

Btw, this is the repo with my changes: https://github.com/ajpinedam/ChatAppUI

Note: The issue seems to be related to the focus. Notice that the problem only occurs when you dismiss the keyboard using the navigation buttons, and the TextBox keeps the focus. On the other hand, when the Keyboard is dismissed by tapping outside, the error does not happen.

ajpinedam commented 9 months ago

Video showing the sample I ran with Uno 5.0.41:

https://github.com/unoplatform/uno/assets/1900897/da3baa4a-5938-43b5-a0e7-d9ee65db2f87