-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Prevent focus reset for DataGridTemplateColumn #4206
Conversation
Thanks duke7553 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think we want to update the sample here to show this in the example (using the First Ascent column) and expand on how we'd expect a developer to do this behavior?
I was playing a bit around as there's two parts to the DataGridTemplateColumn
the CellTemplate
and the CellEditingTemplate
(as per the original bug vs. the work-around using read-only mode). So, I'd expect you may also want to show the cell as just a text date first before showing the picker vs. always being modifiable? Want to make sure we cover both scenarios with a fix (which I think this does? it's harder to test the existing behavior as the shipped sample app can't use the template column).
I made some updates to the XAML and data model backing the DataGrid sample here to show this (and rebased on top of the latest main as your branch was out of date): https://github.com/michael-hawker/UWPCommunityToolkit/tree/dg-focusreset
Saw in the bug thread I had to use DateTimeOffset
for binding vs DateTime
which is odd but is important. Seems to work like a charm though with the updated example! 🎉
Wonder though if there's the same UX problems this way we had with the ComboBox as well from #3161/#4220 with how CalendarPicker would behave, right? I also noticed that DataGridTemplateColumn
has overrides vs. events, so it's not easy to apply the same fix without asking the developer to create their own subclass of the template column, but then templating is a bit harder to build in that way... would be nice for us to support events, so I'll open a separate issue for that.
Thoughts on all this? @duke7553 if you're happy with my updated demo, please feel free to merge into your branch here for the PR or if you want me to force-push to your remote one (assuming you checked collaborators have write access to the branch in the PR).
Ah, I found the parent DataGrid event. I updated my sample and fixed it so you only need 2 clicks over 3 for the Calendar cell. @duke7553 let me know how we can update your branch the best with the new sample update. I opened a PR on your fork so we could discuss that over there. https://github.com/duke7553/WindowsCommunityToolkit/pull/1 |
|
8,Manaslu,8163,Manaslu Himalaya,28d33m00sN 84d33m35sE,3092,Cho Oyu,05/9/1956,49 (45) | ||
9,Nanga Parbat,8126,Nanga Parbat Himalaya,35d14m14sN 74d35m21sE,4608,Dhaulagiri,07/03/1953,52 (67) | ||
10,Annapurna I,8091,Annapurna Himalaya,28d35m44sN 83d49m13sE,2984,Cho Oyu,06/03/1950,36 (47) | ||
11,Gasherbrum I,8080,Baltoro Karakoram,35d43m28sN 76d41m47sE,2155,K2,01/01/1958,31 (16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I grabbed a couple of the months/dates for testing with the Calendar Picker, but wasn't going to enter them all, so opened #4224 for tracking if a hiking enthusiast wants to help us in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @duke7553! I've updated your branch which has updated the PR here with my sample changes. Feel free to take them for a spin if you'd like too.
Hello @michael-hawker! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Everything looks great. Thank you! |
Note: This is a copy of the previously reviewed work with a new branch name
Fixes #2493
This prevents DataGrid from assuming focus should be reset back to itself when a control inside DataGridTemplateColumn gains focus. This is my first WCT PR, so please go easy on me 😆
PR Type
What kind of change does this PR introduce?
Bugfix
What is the current behavior?
Trying to open a control like CalendarDatePicker from within a DataGridTemplateColumn doesn't work, as there is specific behavior to detect when DataGrid loses focus and return it. This doesn't make much sense for controls which require focus to function properly.
What is the new behavior?
When the DataGrid loses focus, we now specifically detect if the editing column is a DataGridTemplateColumn and alter the behavior to accommodate this.
PR Checklist
Please check if your PR fulfills the following requirements:
Other information
I'm unsure if this is the best way to do this, but it makes the most sense given how DataGrid already has the capability to detect the editing element and column type.
Additional context before branch rename: #4206
Related: unoplatform/uno#6543