-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] RefreshView to completes instantly when using AsyncCommand or Command with CanExecute functionality #14350
Comments
Can confirm this issue as well. |
I noticed several weird things about the |
@cpraehaus is this related to what you did for the ListView in #8384 ? |
I can also confirm this. It bit me when trying to use MvvmCross' |
@Hackmodford do you still have a project where you could try this on? |
@jfversluis I have what I am currently working on. But I can't share that source if that's what you're asking. |
That is definitely not what I'm asking :) This issue has similarities with something we just fixed. So I was wondering if maybe fixed this as well, but it seems the fix was only for ListView so that's not going to work here. I was going to ask if you could try out the fix, but seems that is not necessary |
Your are right @jfversluis, this issue is about the |
That would be amazing, thank you! |
…n#14350 Platform renderers can use IsRefreshAllowed to disable swipe to refresh in a controlled fashion - letting any pending refresh/command finish first to avoid that ongoing refresh indication is stopped prematurely (even if the refresh command is still executing).
Implementations of Reason:
Idea is to introduce a new property Prepared a fix but since this change affects multiple platforms I want to perform some further tests before submitting PR. |
@beeradmoore, a PR (#14837) for this is open now, would you be able to grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process. Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂 Thanks! |
Your link to the PR links to this issue. |
Ha whoops! Sorry about that. Fixed it! |
Wow I really need more coffee. Seems a build has not been triggered for the PR. Doing that now. As soon as it's finished you should be able to try :) thanks! |
@jfversluis looks like the tests failed. |
@Hackmodford it's finally there now! :D |
@jfversluis , I put it in my main work project and did not notice my |
@beeradmoore in other words, this seems to fix it? |
I just tried the PR. On iOS my refresh view is shown at page launch (as I expected). But when I do a pull to refresh it goes away immediately. I will test Android next. |
same behavior on Android.
This is how I originally had my command.
I also tried this.
All scanning is performed by running this command (either via viewAppeared or pulling to refresh). |
@Hackmodford RefreshView works the following way: when user pulls to refresh then Try setting default binding mode for
And change your command implementation as follows:
Hope this helps. |
@Hackmodford Ah sorry, just realized what I suggested is not going to work since you want to use
and
|
what I didn't mention is that |
@jfversluis , yep fixes it. Although discussion on the PR you linked looks like this isn't the solution that will go out and maybe it needs to be done a different way. |
Description
If you have a
RefreshView
to load some data asyncronsly on a pull to refresh the pull to refresh actions (IsRefreshing = false
, animation goes away) will complete differently depending if you are using the normal Command vs Command with CanExecute functionality (Xamarin Community Toolkits AsyncCommand included).This was discovered when I thought it was a problem with
AsyncCommand
(withallowsMultipleExecutions
set to false) in Xamarin Community Toolkit (original issue is filed here), but the last changes to RefreshView by @PureWeen actually added this CanExecute functionality. So this may be by design.IMO if I am using
AsyncCommand
(with allowsMultipleExecutions) I would expect the RefreshView to finish refreshing once the Task has finished executing. When using a regular command (with canExecute functionality setup) I would expect RefreshView to not finish refreshing early but instead wait for the Command to finish executing. It makes sense to not allow refreshing to start if the commandCanExecute = false
, but it shouldn't end it prematurely.Steps to Reproduce
Expected Behavior
When the user pulls to refresh the RefreshView will await for the specific method (ExecuteRefreshCommand in my sample) to finish before setting IsRefreshing to false and making the refresh animation go away.
Actual Behavior
RefreshView completes refresh instantly when RefeshCommand has CanExecute functionality (or is AsyncCommand with allowsMultipleExecutions = false) .
Basic Information
Xamarin.Forms: 5.0.0.2012
Xamarin Community Toolkit: 1.1.0
Environment
Show/Hide Visual Studio info
Screenshots
Command (without canExecute):
Command (with canExecute) or AsyncCommand
Reproduction Link
AsyncCommandRefreshView.zip
Workaround
Now that I understand the underlying issue I will go back to using a regular Command, not implement CanExecute, instead inside my method that is being called add extra checks to avoid it being called multiple times.
This workaround is fine, but IMO it feels the current implementation adds a nice got-ya that people may not be aware of.
The text was updated successfully, but these errors were encountered: