maui
maui copied to clipboard
When using a barcode scanner, the Entry.Completed event is fired with empty Text
Description
When using a barcode scanner the Entry.Completed event is fired before the control is populated with the scanned barcode, and the Text value is Empty or null, and only after the event the Entry control is populated with the correct scanned value, but no Completed event is thrown again, since it already was triggered before.
The Entry.ReturnCommand is also affected with this behavior.
Expected Behavior
Entry.Completed event fired after with the Text property filled with the scanned barcode value.
Checks I already made
- The Entry.Completed event fires with correct Text if the Entry is populated by keyboard ✅
- Pasting the text and hitting enter in the Entry produced the Completed event with correct Text value ✅
- Barcode scanner is correctly configured to append the return key to the scanned value ✅
- Notepad: scanning a barcode adds the correct text and a new line
- other programs recognize the correct input barcode
- Running in release mode yields the same problem ✅
Steps to Reproduce
- dotnet new maui -n maui-scanned-entry
- In MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="maui_barcode_entry_test.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Entry
WidthRequest="500"
HorizontalOptions="Center"
Keyboard="Plain"
Completed="Entry_Completed"
/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
- In MainPage.xaml.cs
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void Entry_Completed(object sender, EventArgs e)
{
Entry entry = sender as Entry;
Trace.WriteLine("Scanned: " + entry.Text);
entry.Text = "";
}
}
- Start project and put focus on Entry
- Scan a barcode in Symbol scanner
- Verify that the trace line is "Scanned:" but the Entry control has text
Link to public reproduction project repository
https://github.com/ruimgoncalves/maui-barcode-entry-test
Version with bug
6.0 Release Candidate 2 or older
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
.NET v7.0.100-rc.2.22477.23
Did you find any workaround?
No response
Relevant log output
No response
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
@ruimgoncalves if you change the field to an editor with multi-line can you tell if it's sending an enter key at the beginning of the entry as well?
The enter key is only being sent at the end, and the Completed event is only triggered when the control loses focus, witch I guess is fine.
There are too many entry bugs in MAUI. Microsoft should have released MAUI as a GA in 2025.