Closed ThatGuyMike7 closed 1 year ago
I noticed the same behavior in the Demo App.
We have to clic outside the textbox do be able to edit the cell.
I had the behavior in my app. I found a workaround.
Set the Focusable
of the ScrollViewer
above the DataGrid
to False
.
<ScrollViewer
Focusable="False">
...
<DataGrid>
...
In the Demo App, I fix this line. https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/a4a5cd21e328ce1e473811ad330a40e5f9ac1d55/MainDemo.Wpf/MainWindow.xaml#L220
However, I am not sure what the cause is.
I think setting DataGridAssist.EnableEditBoxAssist="False" resolves the issue? Unfortunately it re-establishes the double-click to edit (default) behaviour.
My uneducated guess would be that the AllowDirectEditWithoutFocus() method appears to work the first time when clicking directly on an element inside a datagrid cell, but won't work again unless the user either clicks outside of the contained element but still in the target cell, OR they click on another element in a different row.
Please confirm.
@jbooth88 I think you are right about the AllowDirectEditWithoutFocus()
being the culprit. I have added a very simple PR which simply bails out of that method in case the cell is already being edited. I think this is what the user would want.
@Xaalek Could you test it out using the code from the PR (see above)?
It's better than before but we still have something weird. Depending on where we click on the cell the behavior is different. I also noticed something weird with the style MaterialDesignDataGridTextColumnPopupEditingStyle. To open the edition we have to click on the edge of the cell. Moreover the pop up doesn't open at the right place. https://youtu.be/pWXAf7tRK1Q
Unfortunately, there are no specs for editable datagrids. However, we could be inspired by this library to do the job https://mui.com/x/react-data-grid/ (especially for the style with the pop up)
@Xaalek I just played around with the DataGrid
a bit more, and wow it really does have some strange behaviors!
I cannot reproduce the issue with the popup editing being misplaced. It opens fine on mine. I can however reproduce a bunch of different scenarios where the clicks are ignored or do not do what you would want them to.
Those issues were there before the fix in my PR, which only addresses the problem listed in this issue (i.e. the double click to edit was not working). So I guess that should not prevent the PR from being merged (you did say that "it's better than before").
Perhaps we should create another issue for sorting out the strange behaviors of the DataGrid
in general?
@Xaalek I think this was - for the most part - fixed in the latest release? Should we close the issue?
@ThatGuyMike7 Can you reproduce the issue with the latest release? If not, perhaps the issue should be closed?
Looks good to me. I just have the popup issue that is still there.
Bug explanation
When I click twice on a field, its entire row becomes grey and my clicks on the field are ignored (can't edit the value), until I click on another field in another row. It seems to be very unintuitive.
I don't expect two clicks on a field to result in not being able to edit that field anymore.
I use the DataGrid like this:
Version
4.5.0