Bug 44966 - No way to lock focus on Entry or Editor
Summary: No way to lock focus on Entry or Editor
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.2
Hardware: All All
: Low enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-02 10:38 UTC by Alexey Kinev
Modified: 2018-02-22 22:27 UTC (History)
6 users (show)

Tags: entry, editor, focus, view, ac
Is this bug a regression?: No
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 44966 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Alexey Kinev 2016-10-02 10:38:35 UTC
# Steps to reproduce
1. Add any Entry or Editor view on a page and focus on it - software keyboard should appear
2. Tap on any other control, e.g. "Send" button - focus get lost, keyboard hides

# Expected behavior
In many cases, we don't need to unfocus just after clicking on another control! For example, in iOS iMessage or Facebook Messenger apps (actually in many more apps) when sending a message by pressing "Send" button the focus is not lost. And you can just type another message and another one and so on. So buttons clicking are handled without getting focus, it's just different concepts! It's unclear why in the first place does button may need to get focus in a mobile app? It's impossible now to lock focus for input fields in Xamarin.Forms app, it's internally hard-coded behavior.

# Actual behavior
Focus for any input field is always lost on any other active view tap. For example, on pressing "Send" button focus is lost and keyboard hides, and we need to tap input field again to send another message.

# Suggestion

I suggest adding `IsFocusable` property to the `View` class and if it's set to `false`, then that instance won't capture focus. It's simple non-breaking change that will increase flexibility and solve the problem.

# Related links

http://forums.xamarin.com/discussion/77871/how-to-lock-focus-on-editor-view#latest
Comment 1 adrianknight89 2016-10-12 01:35:11 UTC
What happens if you set IsEnabled to false on other controls? Does the keyboard still hide?

Also, in iMessage window, I believe the textbox and the send button are PART of the keyboard. I recently worked on https://github.com/xamarin/Xamarin.Forms/pull/407 though it doesn't have an option to add an Entry. You could use system buttons whose actions DO NOT call unfocus.
Comment 2 Alexey Kinev 2016-10-12 06:15:33 UTC
> What happens if you set IsEnabled to false on other controls? Does the keyboard still hide?

Not tested yet and probably for some cases it can be a workaround. But I might want to have many interactive elements which don't catch focus. Like I may want to enable copy & paste actions for messages on long tap. And the keyboard doesn't need to be hidden on this action.

On iOS, only another input may intercept focus automatically but not button or other interactive control.

We just need more native UX / UI and this is one of the patterns which breaks it.

> Also, in iMessage window, I believe the textbox and the send button are PART of the keyboard.

Not sure if it possible at all. In every tutorial about such construction, I saw that animation is required to move controls up and down on keyboard events.

It's possible to add buttons, but I never saw that it's possible to add an input field.
Comment 3 adrianknight89 2016-10-12 06:23:12 UTC
Ah. Now that I looked at iOS 10 again, it's more evident that the controls are not part of the keyboard. I agree that this kind of functionality should be added. It'd be very useful.
Comment 4 FieldstrikeMobile 2017-09-21 08:19:48 UTC
useful feature. Especially when supplying a custom onscreen keyboard
Comment 5 Dennis 2018-01-23 08:42:09 UTC
Also working on a chat app here, this would GREATLY improve QOL.
Comment 6 Bernard Blanckaert 2018-02-22 22:27:55 UTC
Tis would also increase the consistency between native platforms. After some testing it occurs that for IOS not all elements tapped 'steal' the focus (ex List item tabbed do not grab focus) while on Android more elements take always the focus )list items tapped grab the focus). Having a clear property that controls which elements should grab focus would bring clarity to how focus is handed and give back control to the developer across platforms. 

Being able to control the focus grabbing capabilities per elements should be very helpful in creating more platform consistent, robust and improved UI experiences.

I support the fix and would urge to have the importance increased to High instead. 
Solutions around this problem for now forces people to be very creative with dirty hacks which will surely not be future proof. 

Priotisation of this issue is advised and would be very welcomed.