maui icon indicating copy to clipboard operation
maui copied to clipboard

[Android] Prevent Picker from Gaining Focus on Touch

Open bhavanesh2001 opened this issue 7 months ago • 6 comments

[!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 brings Picker behavior on Android in line with DatePicker and TimePicker, in support of the enhancement described in #8945.

Currently, the Picker's platform control is focusable on touch, and a lot of custom logic has been implemented to make it work with this focus behavior. However, even with that logic, the platform control does not lose focus automatically when the dialog is dismissed — the Focus event fires, but the corresponding Unfocus event does not trigger when the dialog closes. This has led to some weird bugs.

In contrast, both DatePicker and TimePicker are not focusable on touch, so obviously, their Focused and Unfocused events do not fire.

This PR makes Picker behave the same way — by making it non-focusable on Touch, we avoid the current awkward focus lifecycle and ensure consistent behavior across all picker types, paving the way for future improvements with #8945.

CC @PureWeen

Supersedes #25319

Related to #8946 Related to #6252

Issues Fixed

Fixes #19739 Fixes #8546 Fixes #13503 Fixes #24862 Fixes #28121 Fixes #21704 Fixes #15394

bhavanesh2001 avatar Apr 17 '25 19:04 bhavanesh2001

Making a note here that we need to validate keyboard interactions and TalkBack to make sure everything works as expected

PureWeen avatar Apr 22 '25 22:04 PureWeen

/azp run

PureWeen avatar Jun 14 '25 13:06 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jun 14 '25 13:06 azure-pipelines[bot]

We should make sure to maintain this behavior https://github.com/dotnet/maui/pull/25319#pullrequestreview-2393277222

PureWeen avatar Jun 14 '25 15:06 PureWeen

/azp run

PureWeen avatar Jun 15 '25 16:06 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jun 15 '25 16:06 azure-pipelines[bot]

/azp run

PureWeen avatar Jun 17 '25 17:06 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jun 17 '25 17:06 azure-pipelines[bot]