Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/LiveComponent/assets/dist/live_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,7 @@ class Component {
if (!controls.shouldRender) {
return;
}
this.hooks.triggerHook('loading.state:finished', this.element);
if (backendResponse.response.headers.get('Location')) {
if (this.isTurboEnabled()) {
Turbo.visit(backendResponse.response.headers.get('Location'));
Comment on lines +2155 to 2158
Copy link
Member

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') || '';

Copy link
Author

@sukei sukei Apr 22, 2025

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?

Expand All @@ -2161,7 +2162,6 @@ class Component {
}
return;
}
this.hooks.triggerHook('loading.state:finished', this.element);
const modifiedModelValues = {};
Object.keys(this.valueStore.getDirtyProps()).forEach((modelName) => {
modifiedModelValues[modelName] = this.valueStore.get(modelName);
Expand Down
10 changes: 5 additions & 5 deletions src/LiveComponent/assets/src/Component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ export default class Component {
return;
}

// remove the loading behavior now so that when we morphdom
// "diffs" the elements, any loading differences will not cause
// elements to appear different unnecessarily
this.hooks.triggerHook('loading.state:finished', this.element);

if (backendResponse.response.headers.get('Location')) {
// action returned a redirect
if (this.isTurboEnabled()) {
Expand All @@ -362,11 +367,6 @@ export default class Component {
return;
}

// remove the loading behavior now so that when we morphdom
// "diffs" the elements, any loading differences will not cause
// elements to appear different unnecessarily
this.hooks.triggerHook('loading.state:finished', this.element);

/**
* For any models modified since the last request started, grab
* their value now: we will re-set them after the new data from
Expand Down
Loading