xamarin/Xamarin.Forms

Entry keyboard changed to default when setting entry text from behavior.

Open

#5,561 opened on Mar 14, 2019

 (1 comment) (0 reactions) (0 assignees)C# (1,926 forks)batch import
e/3 :clock3:hackathonhelp wantedinactivep/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

I have a behavior on an Entry control. The behavior was to add a mask to the text while you enter it (from https://xamarinhelp.com/masked-entry-in-xamarin-forms/).

I noticed that whenever the behavior applied the mask, the keyboard was set back to the default one. IE if I set focus to the entry, then change the keyboard to the number keyboard and type numerical characters, the keyboard would switch back to the alphabet keyboard as soon as the mask was added.

I narrowed it down to these two lines that appear to be causing this: var entry = sender as Entry; entry.Text = "foo";

(in OnEntryTextChanged in the behavior).

Steps to Reproduce

  1. Click the entry box.
  2. Switch the keyboard to numerical keyboard.
  3. Type "1" (or anything) so that the OnEntryTextChanged will fire in the behavior.

Expected Behavior

"foo" displays in the entry and the keyboard is still the numeric keyboard.

Actual Behavior

"foo" displays in the entry, BUT the keyboard is now back to the default one.

Basic Information

This seems to be only on Android.

  • Version with issue: Latest Xamarin
  • IDE: Visual Studio 2017 Pro
  • Platform Target Frameworks:
    • Android: 8.1
  • Netstandard 2.0

Screenshots

Default keyboard when you tap into the entry (step 1): image

Numeric keyboard (Step 2): image

Keyboard defaulted after step 3: image

This is the test app I've used: App4.zip

Contributor guide