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 HideSoftInputOnTapped Not Working Net9 #28534

Merged
merged 5 commits into from
Mar 24, 2025

Conversation

SuthiYuvaraj
Copy link
Contributor

@SuthiYuvaraj SuthiYuvaraj commented Mar 20, 2025

Issue Description

When the MainPage is set as the direct window, enabling HideSoftInputOnTapped prevents the keyboard from hiding when tapping on the screen.

Root Cause

The page receives touch input through ResignFirstResponderTouchGestureRecognizer, controlled by the HasNavigatedTo value. This mechanism applies to both UpdateFocusForView and SetHideSoftInputTapped. For a direct ContentPage, HasNavigatedTo remains false but updates to true in SendNavigatingTo when used within NavigationPage. Hence this works fine for the navigation page.

Description of Change

During UpdatePage, when adding the page to the collection, the parent is checked. If it is a direct window, the page is added to the collection. Additionally, the page count is considered for FeatureEnabled and the OnTapped event to handle HideSoftInput.

Issues Fixed

Fixes #26792
Fixes #21681

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshot

Before Issue Fix After Issue Fix
HideSoftBeforeFix.mov
HideSoftAfterFix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Mar 20, 2025
Copy link
Contributor

Hey there @SuthiYuvaraj! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Mar 20, 2025
@mattleibow mattleibow added the area-keyboard Keyboard, soft keyboard label Mar 21, 2025
@SuthiYuvaraj SuthiYuvaraj marked this pull request as ready for review March 21, 2025 11:31
@Copilot Copilot bot review requested due to automatic review settings March 21, 2025 11:31
@SuthiYuvaraj SuthiYuvaraj requested a review from a team as a code owner March 21, 2025 11:31

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issue #26792 by ensuring that the HideSoftInputOnTapped feature works correctly even when a ContentPage is set as the direct window. Key changes include:

  • Adding UI test cases in both TestCases.Shared.Tests and TestCases.HostApp.
  • Modifying conditionals in HideSoftInputOnTappedChangedManager and its platform-specific implementations to consider pages whose Parent is a Window.
  • Updating Android-specific code to align with the new condition.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26792.cs Added test case to verify soft keyboard behavior
src/Controls/tests/TestCases.HostApp/Issues/Issue26792.cs Updated UI for Issue26792 to support HideSoftInputOnTapped
src/Controls/src/Core/ContentPage/HideSoftInputOnTappedChanged/HideSoftInputOnTappedChangedManager.cs Updated conditional to check for direct window usage
src/Controls/src/Core/ContentPage/HideSoftInputOnTappedChanged/HideSoftInputOnTappedChangedManager.Android.cs Updated condition for Android platform-specific handling
src/Controls/src/Core/ContentPage/HideSoftInputOnTappedChanged/HideSoftInputOnTappedChangedManager.Platform.cs Updated condition in UpdatePage to handle direct window
@rmarinho rmarinho requested a review from tj-devel709 March 21, 2025 11:45
@rmarinho rmarinho changed the base branch from main to inflight/current March 21, 2025 12:13
@rmarinho
Copy link
Member

/rebase

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just blocking as something is triggering my brain... This HasNavigatedTo property, should it be set to true in this instance?

Almost like if you set Window.Page = somthing, that something is supposed to get auto navigated to?

@mattleibow
Copy link
Member

I feel like this PR fixes a symptom of another problem in this PR: #23420

@mattleibow
Copy link
Member

Maybe we can land this PR now to get the issue fixed, and then we can fix it properly and remove this workaround? @PureWeen

@mattleibow mattleibow requested a review from PureWeen March 24, 2025 12:55
Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for now as this code is fine based on the current state of the system. However, a better fix is needed which was started in #23420

@mattleibow mattleibow merged commit f3ec03b into dotnet:inflight/current Mar 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-keyboard Keyboard, soft keyboard community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HideSoftInputOnTapped Not Working Net9
3 participants