Event order between entry and collection different in Windows and Android
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
I'm trying to write code that updates a list item only when data entry is completed so the basic idea is to load the entry data from the selected list item, allow the user to edit it, then put the changed value back in the list entry once the user focuses on a field other than the entry field.
The issue arises when the user makes a change in the entry field then selects an item from the list, the events of interest are the entry field Unfocus and the list (a CollectionView) SelectionChanged event, on android the Unfocus comes first, then the selection change, this seems like the right order. On Windows the order is reversed so by the time Unfocus is invoked the selection has already changed, which is a Bad Thing.
### Steps to Reproduce
1. Unzip [MAUIListEntry-EventOrder.zip](https://github.com/dotnet/maui/files/8309751/MAUIListEntry-EventOrder.zip)
2. Run it on Android then on windows, perform the following steps in each case
3. Click on the first item in the list
4. Click on the entry field
5. Click on the second item in the list
On Android you'll see this in the Debug Output window:
```
[0:] >>> In Entry_Focused at line 23
[0:] >>> In Entry_Unfocused at line 28
[0:] >>> In LineItemsListView_SelectionChanged at line 42
```
But on Windows you'll see this:
```
>>> In Entry_Focused at line 23
>>> In LineItemsListView_SelectionChanged at line 42
>>> In Entry_Unfocused at line 28
```
Note that the last two events happen in reverse order.
### Version with bug
Preview 14 (current)
### Last version that worked well
Unknown/Other
### Affected platforms
Windows, I was *not* able test on other platforms
### Affected platform versions
Windows 10
### Did you find any workaround?
I'm guessing the selection is correct at the time Focused is invoked, so it should be possible to code around it but I have not tried.
### Relevant log output
_No response_
Contributor guide
Research direction
Run the attached MAUIListEntry-EventOrder.zip on Android and Windows 10, then reproduce the three-step interaction and compare the Focused, Unfocused, and CollectionView SelectionChanged logs. Read the sample handlers and the platform-specific CollectionView or focus behavior involved; done means the event order is understood and the documented behavior is consistent or clearly explained across platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp
- Domain
- desktop-dev, frontend, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100