Skip to content

Commit e892ae4

Browse files
committed
Release the loading state before any redirect.
1 parent af16ce1 commit e892ae4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,7 @@ class Component {
21522152
if (!controls.shouldRender) {
21532153
return;
21542154
}
2155+
this.hooks.triggerHook('loading.state:finished', this.element);
21552156
if (backendResponse.response.headers.get('Location')) {
21562157
if (this.isTurboEnabled()) {
21572158
Turbo.visit(backendResponse.response.headers.get('Location'));
@@ -2161,7 +2162,6 @@ class Component {
21612162
}
21622163
return;
21632164
}
2164-
this.hooks.triggerHook('loading.state:finished', this.element);
21652165
const modifiedModelValues = {};
21662166
Object.keys(this.valueStore.getDirtyProps()).forEach((modelName) => {
21672167
modifiedModelValues[modelName] = this.valueStore.get(modelName);

src/LiveComponent/assets/src/Component/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ export default class Component {
351351
return;
352352
}
353353

354+
// remove the loading behavior now so that when we morphdom
355+
// "diffs" the elements, any loading differences will not cause
356+
// elements to appear different unnecessarily
357+
this.hooks.triggerHook('loading.state:finished', this.element);
358+
354359
if (backendResponse.response.headers.get('Location')) {
355360
// action returned a redirect
356361
if (this.isTurboEnabled()) {
@@ -362,11 +367,6 @@ export default class Component {
362367
return;
363368
}
364369

365-
// remove the loading behavior now so that when we morphdom
366-
// "diffs" the elements, any loading differences will not cause
367-
// elements to appear different unnecessarily
368-
this.hooks.triggerHook('loading.state:finished', this.element);
369-
370370
/**
371371
* For any models modified since the last request started, grab
372372
* their value now: we will re-set them after the new data from

0 commit comments

Comments
 (0)