Skip to content

[Discussion] Unfocus Android controls behavior vs accessibility #25688

@lobbo232

Description

@lobbo232

Hi! We understand that this was a behavior change from Xamarin.Forms, but it was an intentional one. We do not consider this to be a bug.

Please see this comment from Rachel on #11881.

Hi All,

In developing .NET MAUI, we learned that it is not possible on earlier versions of Android to unfocus an entry. Some control must always be focused. In Xamarin.Forms, this was approached by setting focus on the page layout; unfortunately, this approach created major accessibility issues. For these reasons, .NET MAUI no longer allows for this behavior by default.

If this antipattern can be avoided, we highly recommend using a different approach. If it cannot be avoided, we'd love to learn more about your scenario so that we can better understand your development needs! That being said, we do understand the needs from a migration compatibility standpoint, so for those scenarios, there is a new property that was introduced in .NET 8. Using HideSoftInputOnTapped should do the trick.

.NET MAUI aims to be as accessible as possible with little interaction from developers, so we will not revert this behavior. Thank you for understanding.

Originally posted by @samhouts in #21053

@samhouts I don't think we are understanding. Issues are being created constantly related to this.

Why would preventing an un-focussing action from triggering the unfocussed event increase accessibility? Can you help us understand the thought process here and perhaps give a reason as to why we can't have this behaviour in our own apps? This seems to reduce accessibility in most scenarios.

The HideSoftInputOnTapped alternative closes the input but doesn't trigger the Unfocussed events. Is this also intentional? Seems broken to me.

The TextChanged event is a terrible option due to the inefficiency of firing the event on every single key press.

It seems that the whole community wants this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions