.Net 7 Android Unfocused Entry Behavior only gets called when leaving the page
See original GitHub issueDescription
This works as expected in iOS. In Android, Unfocused only gets called when leaving the page. It does not get called when you leave the Entry field.
Steps to Reproduce
Create an Entry in Xaml.
<Entry Grid.Row="1" x:Name="nameEntry" Grid.Column="0" Placeholder="Enter a screen name."
HorizontalOptions="Center" Style="{StaticResource Label_ProfileViewName}"
Text="{Binding SelectedPlayer.ScreenNameEntry}" TextChanged="entry_name_TextChanged" IsTextPredictionEnabled="false">
<Entry.Behaviors>
<local:CheckNameBehavior x:Name="checkScreenName"/>
</Entry.Behaviors>
</Entry>
Create a Behavior like so.
public class CheckNameBehavior : Behavior<Entry>
{
static readonly BindablePropertyKey IsValidPropertyKey = BindableProperty.CreateReadOnly("IsValid", typeof(bool), typeof(CheckNameBehavior), false);
static readonly BindableProperty IsValidProperty = IsValidPropertyKey.BindableProperty;
public bool IsValid
{
get { return (bool)base.GetValue(IsValidProperty); }
private set { base.SetValue(IsValidPropertyKey, value); }
}
protected override void OnAttachedTo(Entry bindable)
{
bindable.Unfocused += HandleFocusChanged;
}
protected override void OnDetachingFrom(Entry bindable)
{
bindable.Unfocused -= HandleFocusChanged;
}
async void HandleFocusChanged(object sender, FocusEventArgs e)
{
Entry entry = sender as Entry;
}
}
Link to public reproduction project repository
https://github.com/dotnet/maui/
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 31 with a target of 33
Did you find any workaround?
Nope, there is no workaround.
Relevant log output
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
android - .NET MAUI Entry keyboard does not hide
Known bug. Removing the focus sometimes helps. Sometimes you need to do Disable/Enable in sequence. (I go with the second).
Read more >AutoComplete in UI for .NET MAUI | Telerik Forums
On Android in order to unfocus the control, you need to call Unfocus() method or focusing another element that receives focus (another entry)....
Read more >Entry - .NET MAUI
Gets or sets the opacity value applied to the element when it is rendered. This is a bindable property.
Read more >Focused/Unfocused behaves differently on Android ...
On iOS it works fine, but on Android because focused is called first and then unfocused, wheelPicker becomes invisible which is wrong. Need ......
Read more >SetFocusOnEntryCompletedBeh...
The SetFocusOnEntryCompletedBehavior is a Behavior that gives focus to a specified VisualElement when an Entry is completed.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@PureWeen I can confirm that this is still happening! Can you please kindly answer, why is this being ignored for 8 months now? It basically prevents us from migrating to MAUI!
@PureWeen i can also confirm the issue is still existed. and its very important for my app also