-
-
Notifications
You must be signed in to change notification settings - Fork 391
[LiveComponent] Release the loading state before any redirect. #2689
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
base: 3.x
Are you sure you want to change the base?
Conversation
📊 Packages dist files size differenceℹ️ No difference in dist packagesFiles. |
| this.hooks.triggerHook('loading.state:finished', this.element); | ||
| if (backendResponse.response.headers.get('Location')) { | ||
| if (this.isTurboEnabled()) { | ||
| Turbo.visit(backendResponse.response.headers.get('Location')); |
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'm not sure we want to trigger the "finished" event before Turbo does its work.
Here you could do something just before the
window.location.href = backendResponse.response.headers.get('Location') || '';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 use Turbo on this project and I need it to be triggered in that setup too. BTW, I'm actualy using this patch and it didn't seems to create any issues.
EDIT : I disabled Turbo in that case to avoid a double fetch of the URL, that may be the reason I didn't have any issue. So WDYT? Should I move the call?
e892ae4 to
23203ac
Compare
|
Rebase on 3.x, still apply. |
This PR attempt to release the loading state before redirecting the user. This one may seems a little weird at first, but it has its use case.
I just write an export feature that uses a LiveComponent action to build a file. While the export is made, the UI add some classes and/or attributes to convey the "in progress" meaning. When it's done, the user is redirected to a specific controller that initiate the download. Since the redirected page just provide a file attachment, the user stay on the original page (fully expected). But, at this stage, the loading state is never released. By releasing the loading state before the redirect, the UI is made responsive again.