-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix Android layout jump when navigating with IME open and NavBarIsVisible=false #34621
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
Open
jpd21122012
wants to merge
3
commits into
dotnet:main
Choose a base branch
from
jpd21122012:fix/34584-Shell-NavBar-SafeAreaEdges
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+139
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 34584, "Content renders under status bar when navigating with keyboard open to a page with NavBarIsVisible=False", PlatformAffected.Android)] | ||
| public class Issue34584 : TestShell | ||
| { | ||
| protected override void Init() | ||
| { | ||
| var mainPage = new Issue34584_MainPage(); | ||
| var destinationPage = new Issue34584_DestinationPage(); | ||
|
|
||
| AddContentPage(mainPage, "MainPage"); | ||
| AddContentPage(destinationPage, "DestinationPage"); | ||
| } | ||
| } | ||
|
|
||
| public class Issue34584_MainPage : ContentPage | ||
| { | ||
| public Issue34584_MainPage() | ||
| { | ||
| var entry = new Entry | ||
| { | ||
| Placeholder = "Tap here to open keyboard", | ||
| AutomationId = "Entry" | ||
| }; | ||
|
|
||
| var navigateButton = new Button | ||
| { | ||
| Text = "Navigate", | ||
| AutomationId = "NavigateButton" | ||
| }; | ||
|
|
||
| entry.Completed += async (s, e) => | ||
| { | ||
| await Shell.Current.GoToAsync("//DestinationPage", false); | ||
| }; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 20, | ||
| Padding = new Thickness(0), | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Main Page - Tap entry, type text, then navigate", | ||
| FontSize = 18 | ||
| }, | ||
| entry, | ||
| navigateButton | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public class Issue34584_DestinationPage : ContentPage | ||
| { | ||
| public Issue34584_DestinationPage() | ||
| { | ||
| Shell.SetNavBarIsVisible(this, false); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Destination Page", | ||
| FontSize = 24, | ||
| AutomationId = "TargetLabel" | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34584.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #if ANDROID | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue34584 : _IssuesUITest | ||
| { | ||
| public Issue34584(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Content renders under status bar when navigating with keyboard open to a page with NavBarIsVisible=False"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Shell)] | ||
| public void ContentShouldNotRenderUnderStatusBarAfterNavigatingWithKeyboardOpen() | ||
| { | ||
| // Wait for the main page | ||
| App.WaitForElement("Entry"); | ||
|
|
||
| // Open keyboard | ||
| App.Tap("Entry"); | ||
| App.EnterText("Entry", "test"); | ||
|
|
||
| // Navigate while keyboard is open | ||
| App.PressEnter(); | ||
|
|
||
| // Wait for destination page | ||
| App.WaitForElement("TargetLabel"); | ||
|
|
||
| // Poll for a short period to detect transient layout issues during navigation | ||
| bool foundInvalidPosition = false; | ||
|
|
||
| var start = DateTime.UtcNow; | ||
| var timeout = TimeSpan.FromSeconds(1); | ||
|
|
||
| while (DateTime.UtcNow - start < timeout) | ||
| { | ||
| var rect = App.FindElement("TargetLabel").GetRect(); | ||
|
|
||
| // Small threshold to account for device differences | ||
| if (rect.Y < 5) | ||
| { | ||
| foundInvalidPosition = true; | ||
| break; | ||
| } | ||
|
|
||
| System.Threading.Thread.Sleep(50); | ||
| } | ||
|
|
||
| Assert.That(foundInvalidPosition, Is.False, | ||
| "TargetLabel was temporarily rendered under the status bar"); | ||
| } | ||
| } | ||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.