-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Android] Keyboard navigation does not work with RadioButtons with redefined appearance #30041
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
base: main
Are you sure you want to change the base?
Conversation
…defined appearance
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this 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 fixes the bug where RadioButton controls with a redefined ControlTemplate were not fully keyboard-navigable on Android. Key changes include:
- Adding a property to store the ContentViewGroup and subscribing to its KeyPress event.
- Removing existing content views and re-adding the presented content.
- Implementing a key press handler to toggle the radio button state on Enter/Space key presses.
Comments suppressed due to low confidence (1)
src/Controls/src/Core/RadioButton/RadioButton.Android.cs:7
- [nitpick] Consider renaming the property 'contentViewGroup' to 'ContentViewGroup' to follow .NET PascalCase naming conventions for properties.
ContentViewGroup? contentViewGroup { get; set; }
if (e?.Event is not null && e.Event.Action == Android.Views.KeyEventActions.Down && | ||
(e.Event.KeyCode == Android.Views.Keycode.Enter || e.Event.KeyCode == Android.Views.Keycode.Space)) | ||
{ | ||
IsChecked = !IsChecked; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After toggling 'IsChecked' on key press, consider setting 'e.Handled = true' within this block to prevent further propagation of the key event.
IsChecked = !IsChecked; | |
IsChecked = !IsChecked; | |
e.Handled = true; |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test case for this? For Android, can use the App.SendKeys
method to send Tab key.
I will add a test once we decide if this PR makes sense or we should take a different approach |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
This PR fixes a bug where RadioButton controls using a ControlTemplate do not support keyboard navigation (using arrow keys or Tab), breaking the expected accessibility behavior.
When a ControlTemplate is applied, the internal focusable or input-handling elements may be bypassed or not properly initialized for keyboard interaction. This change ensures that:
Issues Fixed
Fixes #30040
Screen.Recording.2025-06-18.at.01.04.47.mov
Screen.Recording.2025-06-18.at.01.07.13.mov