You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered a possible bug while trying to debug another issue I was running into, where pressing 'enter' on a row with editable content was not enabling text editing (very similar to this StackOverflow question). I found that every time the NSOutlineView's selection changed, every unexpanded item visible in the view was being reloaded. This was happening in the following point of OutlineViewUpdater.performUpdates:
if !diff.isEmpty || oldIDs != newIDs {
// Parent needs to be updated as the children have changed.
// Children are not reloaded to allow animation.
outlineView.reloadItem(parent, reloadChildren:false)}
I'm not sure if excessive reloading could cause any other problems besides blocking the 'enter' key behavior.
In trying to fix the 'enter' issue, the suggested fix from the SO post (calling reloadData(forRowIndexes:columnIndexes:) didn't work, so I tried changing the above code from OutlineViewUpdater to this:
if !diff.isEmpty || oldIDs != newIDs {
// Parent needs to be updated as the children have changed.
// Children are not reloaded to allow animation.
letrow= outlineView.row(forItem: parent)letoldParentValue= outlineView.item(atRow: row)as?OutlineViewItem<Data>if oldParentValue != parent {
outlineView.reloadItem(parent, reloadChildren:false)}}
That fixed the problem, and resulted in reloadItem not being called so frequently, but did cause OutlineViewUpdaterTests to fail-- outlineView.reloadedItems came out as [0, 1, 3, 6] instead of the expected [nil, 0, 1, 3, 6].
It seems to me that not reloading nil in the test case is probably fine, since reloadItem(nil) causes the entire NSOutlineView's contents to be reloaded, and I don't think that's what we want in the OutlineViewUpdater. But that change of code could lead to other problems. Since equality between oldParentValue and parent is determined by id rather than more detailed equality checks, updating data externally could lead to some rows not being updated (say, if you change the name of an item but not its id). So I'm a bit stumped on what the best way of dealing with this should be. Maybe nothing, unfortunately.
The text was updated successfully, but these errors were encountered:
I discovered a possible bug while trying to debug another issue I was running into, where pressing 'enter' on a row with editable content was not enabling text editing (very similar to this StackOverflow question). I found that every time the
NSOutlineView
's selection changed, every unexpanded item visible in the view was being reloaded. This was happening in the following point ofOutlineViewUpdater.performUpdates
:I'm not sure if excessive reloading could cause any other problems besides blocking the 'enter' key behavior.
In trying to fix the 'enter' issue, the suggested fix from the SO post (calling
reloadData(forRowIndexes:columnIndexes:)
didn't work, so I tried changing the above code fromOutlineViewUpdater
to this:That fixed the problem, and resulted in
reloadItem
not being called so frequently, but did causeOutlineViewUpdaterTests
to fail--outlineView.reloadedItems
came out as[0, 1, 3, 6]
instead of the expected[nil, 0, 1, 3, 6]
.It seems to me that not reloading
nil
in the test case is probably fine, sincereloadItem(nil)
causes the entireNSOutlineView
's contents to be reloaded, and I don't think that's what we want in theOutlineViewUpdater
. But that change of code could lead to other problems. Since equality betweenoldParentValue
andparent
is determined byid
rather than more detailed equality checks, updatingdata
externally could lead to some rows not being updated (say, if you change the name of an item but not itsid
). So I'm a bit stumped on what the best way of dealing with this should be. Maybe nothing, unfortunately.The text was updated successfully, but these errors were encountered: