Skip to content
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

adapt_framework: Reset on revisit isn't complete before page render #3014

Closed
oliverfoster opened this issue Jan 12, 2021 · 1 comment · Fixed by #3016
Closed

adapt_framework: Reset on revisit isn't complete before page render #3014

oliverfoster opened this issue Jan 12, 2021 · 1 comment · Fixed by #3016
Assignees
Labels

Comments

@oliverfoster
Copy link
Member

oliverfoster commented Jan 12, 2021

Subject of the issue

The code to reset on revisit now lives in the preRender function of the PageView.

this.model.getAllDescendantModels().forEach(model => {
if (!model.checkIfResetOnRevisit) return;
model.checkIfResetOnRevisit();
});

It causes an asynchronous cascade of resets and completion check in AdaptModel from the components to the page.

checkCompletionStatus() {
// defer to allow other change:_isComplete handlers to fire before cascading to parent
Adapt.checkingCompletion();
_.defer(this.checkCompletionStatusFor.bind(this), '_isComplete');
}
checkInteractionCompletionStatus() {
// defer to allow other change:_isInteractionComplete handlers to fire before cascading to parent
Adapt.checkingCompletion();
_.defer(this.checkCompletionStatusFor.bind(this), '_isInteractionComplete');
}

Which when started by a component are never finished before the page has started nor finished rendering. There are 4 layers of deferred completion checks with components, blocks, articles and pages, but only one defer holding the postRender function of the page. Meaning the postRender calls in sequence with the component completion checks.

_.defer(() => {
// don't call postRender after remove
if (this._isRemoved) return;
this.postRender();
Adapt.trigger(`${type}View:postRender view:postRender`, this);
});

An entire page and its content are rendered before the whole set of descendent models are properly reset on revisit.
This causes issues if the reset state of a block should be derived after the page prerender and before the block is rendered and whilst a component is set to reset on revisit - such is the case in the new version of trickle where trickle will stop only if the block is incomplete, which it should be but isn't yet.

Proposed solution

Have the router perform the reset on revisit and wait for the cascade to finish before rendering the page.

@oliverfoster oliverfoster self-assigned this Jan 12, 2021
@oliverfoster
Copy link
Member Author

oliverfoster commented Jan 12, 2021

Accidentally commit fix to master on eed48b3 reverted on c29e0f9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant