Skip to content

fix(droid): hide keyboard when onfocused #20692

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
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ajpinedam
Copy link
Contributor

GitHub Issue: closes #20564

PR Type:

  • 🐞 Bugfix

What is the current behavior? πŸ€”

What is the new behavior? πŸš€

PR Checklist βœ…

Please check if your PR fulfills the following requirements:

Other information ℹ️

@Copilot Copilot AI review requested due to automatic review settings June 4, 2025 04:59
@github-actions github-actions bot added platform/android πŸ€– Categorizes an issue or PR as relevant to the Android platform area/skia ✏️ Categorizes an issue or PR as relevant to Skia labels Jun 4, 2025
@ajpinedam ajpinedam self-assigned this Jun 4, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

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 refines keyboard hiding behavior on Android by checking if the next focused element requires text input before calling HideTextInput.

  • Extends the condition to include multiple input controls (TextBox, AutoSuggestBox, NumberBox).
  • Introduces IsFocusingElementKeyboardActivator and CouldRequireKeyboard helper methods.
  • Updates comments to clarify new logic and prevent keyboard flicker.
Comments suppressed due to low confidence (2)

src/Uno.UI.Runtime.Skia.Android/AndroidSkiaTextBoxNotificationsProviderSingleton.cs:39

  • The method name IsFocusingElementKeyboardActivator is misleading, as it returns true when the next element does not require the keyboard. Consider renaming it to ShouldHideKeyboard or IsNextElementNotKeyboardInput for clarity.
if (IsFocusingElementKeyboardActivator(textBox.XamlRoot))

src/Uno.UI.Runtime.Skia.Android/AndroidSkiaTextBoxNotificationsProviderSingleton.cs:39

  • This new branching logic for hiding the keyboard should be covered by unit or integration tests to verify that HideTextInput is only called when appropriate (e.g., when focusing away from and to an input control).
if (IsFocusingElementKeyboardActivator(textBox.XamlRoot))

{
canvasView.TextInputPlugin.HideTextInput();
}

canvasView.TextInputPlugin.NotifyViewExited(textBox.GetHashCode());
}

static bool IsFocusingElementKeyboardActivator(XamlRoot? xamlRoot)
Copy link
Preview

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

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

The CouldRequireKeyboard method uses a hardcoded list of control types and will need updates whenever new text-input controls are introduced. Consider defining an interface or attribute for keyboard-activating controls to make this more extensible.

Copilot uses AI. Check for mistakes.

@unodevops
Copy link
Contributor

πŸ€– Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-20692/wasm-skia-net9/index.html

@unodevops
Copy link
Contributor

πŸ€– Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-20692/docs/index.html

@unodevops
Copy link
Contributor

⚠️⚠️ The build 167640 has failed on Uno.UI - CI.

@ajpinedam
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@ajpinedam ajpinedam requested a review from jeromelaban June 5, 2025 15:17
@unodevops
Copy link
Contributor

πŸ€– Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-20692/docs/index.html

@unodevops
Copy link
Contributor

πŸ€– Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-20692/wasm-skia-net9/index.html

@unodevops
Copy link
Contributor

⚠️⚠️ The build 167787 has failed on Uno.UI - CI.

@ajpinedam ajpinedam force-pushed the fix/droid.unfocus.keyboard branch from e602b65 to 2437c8e Compare June 6, 2025 05:12
@unodevops
Copy link
Contributor

πŸ€– Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-20692/wasm-skia-net9/index.html

@unodevops
Copy link
Contributor

πŸ€– Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-20692/docs/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/skia ✏️ Categorizes an issue or PR as relevant to Skia platform/android πŸ€– Categorizes an issue or PR as relevant to the Android platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Tapping outside input does not close soft input pane
2 participants