Xamarin.forms: `Focus` is not consistent on all platforms

Created on 19 Mar 2019  路  2Comments  路  Source: xamarin/Xamarin.Forms

Description

This is a larger issue that requires some discussion. The basic summary is this:

All Xamarin.Forms controls are VisualElements, which contains a basic set of properties and events that should work on any VisualElement.

However, the Focus method is not functional on many mobile controls (e.g., Button, WebView) because there is no native option to put focus on such native objects.

Problems:

  1. For many reasons, a11y included, customers would like to put the focus on a Button (or other element) programmatically, and they are currently unable to do so on mobile platforms. Can we do this somehow?

  2. If the answer is No, then should we obsolete the Focus method from VisualElement and move it to a Focusable interface that we can then apply only to elements that are able to be focused? What do we do when that is platform specific?

  3. Moreover, the Focus method is supposed to return a bool value that indicates whether the platform was able to successfully focus the element; in the case of Button, this is erroneously returning true.

7 help wanted high inactive high impact mobcat Android iOS 馃崕 bug up-for-grabs

All 2 comments

FYI to add to the focus fun

https://developer.android.com/about/versions/pie/android-9.0-changes-28

Views with 0 area (either a width or a height is 0) are no longer focusable.

Which is currently causing this
https://github.com/xamarin/Xamarin.Forms/issues/5159

Which now makes the behavior of picker a bit weird because with API 28 we want focus to open the picker but it won't become focused unless we "fake" focus it some how

Was this page helpful?
0 / 5 - 0 ratings