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

Remove "onBeforeRender" event and add "errors" option to preserveScroll and preserveState #628

Merged
merged 1 commit into from Apr 14, 2021

Conversation

reinink
Copy link
Member

@reinink reinink commented Apr 14, 2021

This PR reverts a previous change (#410) that added a new onBeforeRender() event, used by the Vue 2 and Vue 3 form helpers to set form state earlier in the visit lifecycle. As it turns out, this creates other issues, such as the page props being out of date when form.processing returns back to false.

The entire motivation with adding onBeforeRender() was to simplify this:

preserveScroll: (page) => Object.keys(page.props.errors).length > 0,
preserveState: (page) => Object.keys(page.props.errors).length > 0,

To this:

preserveScroll: () => this.form.hasErrors,
preserveState: () => this.form.hasErrors,

Instead of solving the problem that way, I've introduced a new option to preserveScroll and preserveState specifically for preserving the scroll/state when there are errors:

preserveScroll: 'errors',
preserveState: 'errors',

Overall I think this is a much better solution. 👍

@reinink reinink merged commit 370fb65 into master Apr 14, 2021
@reinink reinink deleted the remove-onbeforerender branch April 14, 2021 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants