Add EmptyContent parameter to Virtualize component#49185
Add EmptyContent parameter to Virtualize component#49185SteveSandersonMS merged 4 commits intodotnet:mainfrom etemi:issue-28770
Conversation
|
Thanks for your PR, @etemi. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
mkArtakMSFT
left a comment
There was a problem hiding this comment.
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.
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_loadingflag 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
_loadingflag 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.
Absolutely. This is the better approach - thanks!
Added a new commit.
Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>
SteveSandersonMS
left a comment
There was a problem hiding this comment.
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