Skip to content

Commit

Permalink
Changes to avoid an EditText issue (#5003)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz authored Mar 3, 2022
1 parent c49211c commit 20657cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected override void UpdateTextColor()
_textColorSwitcher.UpdateTextColor(EditText, Element.TextColor);
}

[PortHandler]
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
Expand Down
12 changes: 12 additions & 0 deletions src/Core/src/Handlers/Editor/EditorHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ protected override AppCompatEditText CreatePlatformView()

protected override void ConnectHandler(AppCompatEditText platformView)
{
platformView.ViewAttachedToWindow += OnPlatformViewAttachedToWindow;
platformView.TextChanged += OnTextChanged;
platformView.FocusChange += OnFocusedChange;
}

protected override void DisconnectHandler(AppCompatEditText platformView)
{
platformView.ViewAttachedToWindow -= OnPlatformViewAttachedToWindow;
platformView.TextChanged -= OnTextChanged;
platformView.FocusChange -= OnFocusedChange;
}
Expand Down Expand Up @@ -87,6 +89,16 @@ public static void MapCursorPosition(IEditorHandler handler, ITextInput editor)
public static void MapSelectionLength(IEditorHandler handler, ITextInput editor) =>
handler.PlatformView?.UpdateSelectionLength(editor);

void OnPlatformViewAttachedToWindow(object? sender, ViewAttachedToWindowEventArgs e)
{
if (PlatformView.IsAlive() && PlatformView.Enabled)
{
// https://issuetracker.google.com/issues/37095917
PlatformView.Enabled = false;
PlatformView.Enabled = true;
}
}

void OnTextChanged(object? sender, Android.Text.TextChangedEventArgs e) =>
VirtualView?.UpdateText(e);

Expand Down

0 comments on commit 20657cc

Please sign in to comment.