-
Notifications
You must be signed in to change notification settings - Fork 462
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
Workaround for metrics tree view selection issue #1283
Conversation
@@ -36,7 +36,7 @@ | |||
<FluentTreeItem Class="metrics-tree-item" Text="@meterGroup.Key.MeterName" Data="@meterGroup.Key" title="@meterGroup.Key.MeterName" InitiallyExpanded="true" InitiallySelected="@(_selectedInstrument == null && meterGroup.Key.MeterName == _selectedMeter?.MeterName)"> |
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.
<FluentTreeItem Class="metrics-tree-item" Text="@meterGroup.Key.MeterName" Data="@meterGroup.Key" title="@meterGroup.Key.MeterName" InitiallyExpanded="true" InitiallySelected="@(_selectedInstrument == null && meterGroup.Key.MeterName == _selectedMeter?.MeterName)"> | |
<FluentTreeItem @key="@meterGroup.Key" Class="metrics-tree-item" Text="@meterGroup.Key.MeterName" Data="@meterGroup.Key" title="@meterGroup.Key.MeterName" InitiallyExpanded="true" InitiallySelected="@(_selectedInstrument == null && meterGroup.Key.MeterName == _selectedMeter?.MeterName)"> |
I tested and it is required to stop the first level tree items having the same selection issue.
Unfortunately it introduced a rendering quirk where second level items jump slightly when loaded:
The same thing happened previously when a resource is first selected and the tree is displayed. It wasn't as obvious because it only happened once instead of each time a resource is changed.
Is the rendering jump from items being shown and then web component upgrade?
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.
It shouldn't be web component upgrade - that issue only really happens when the JS isn't loaded when the elements get rendered.
I think what is happening is when tree items are added as children to tree items, they're marked as nested and then the templating for the tree item runs again and that adds nested
to the class. I'd think that would be fast enough we wouldn't notice the rendering, but maybe not.
Another thought is that this could be another issue similar to microsoft/fluentui-blazor#1082 - a similar situation is happening here where FluentTreeItem is setting the class attribute but the underlying tree item is setting it for itself as well (see above). Hrm...
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.
@foreach (var instrument in meterGroup.OrderBy(i => i.Name)) | ||
{ | ||
<FluentTreeItem Class="metrics-tree-item" Text="@instrument.Name" Data="@instrument" title="@instrument.Name" InitiallySelected="@(instrument.Name == _selectedInstrument?.Name && instrument.Parent.MeterName == _selectedMeter?.MeterName)" /> |
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.
metrics-tree-item wasn't being used anymore.
This is a workaround for #1262. We should probably be using
@key
here anyway because of the loop(s). But using it in this way also has the effect of causing blazor to re-render the elements which clears the selection when we want it to.This doesn't solve the fact that setting
_selectedTreeItem
doesn't have the effect we want, just for our use case at the moment this seems sufficient to get by.