-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Add EmptyContent parameter to Virtualize component #49185
Conversation
Thanks for your PR, @etemi. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
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 your PR, @etemi.
@SteveSandersonMS can you please review this? Thanks!
Thanks @etemi! This looks really good. The one thing I think we should change is this:
I think that would be surprising and probably not what developers would want in most cases. Would it work to change this so we only show the "EmptyContent" when the grid is not loading and has zero items? |
Thanks for your feedback @SteveSandersonMS! I changed it so that "EmptyContent" is now only shown when the component is not loading and has zero items. |
finally | ||
{ | ||
_loading--; | ||
} |
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 see what you're doing with the counter here, and think this could work, but also I think there's an alternative that would be better intergrated into the existing flow.
This component already deals with overlapping load operations and knowing when the final one is finished. So, _loading
could be reduced to a bool
flag that gets set to true
above when we set cancellationToken = _refreshCts.Token;
. It can then be set to false
inside the block below next to where we set _itemCount = result.TotalItemCount
etc, because in that block we know this operation wasn't cancelled and therefore it is the last loading operation within the overlapping group. We don't have to worry about exceptions because there are only two cases:
e is OperationCanceledException oce && oce.CancellationToken == cancellationToken
- that means this is not the last loading operation, so we leave the_loading
flag unchanged- Any other exception means it's an unhandled exception and the whole component is going to fail and be torn down, so we can also leave the
_loading
flag unchanged
Would you be OK with trying that approach? I'm asking because a bool
flag is more conventional within this system and fits in with how we already know when the final loading process is finished.
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.
Absolutely. This is the better approach - thanks!
Added a new commit.
Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>
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.
Looks superb - thanks so much for contributing this!
I'll merge this once the build passes.
Adds EmptyContent parameter to Virtualize component
Description
This PR adds the parameter "EmptyContent" to the Virtualize component as proposed in #28770.
Please note that this implementation, when used with an asynchronous ItemsProvider, will render the "EmptyContent" even though the ItemsProvider may not have completed (inital load). It's up to the user of the Virtualize component to "design" the EmptyContent template to show e.g. a progress indicator when data is loaded for the first time.
Feel free to adapt the code/docs as needed.
Fixes #28770