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

Make ZoneGridModel more forgiving (handle possibly out of sync state) #3530

Merged
merged 8 commits into from
Nov 21, 2023

Conversation

febbraiod
Copy link
Member

@febbraiod febbraiod commented Nov 20, 2023

… state)

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

Copy link
Member

@TomTirapani TomTirapani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and taking a look at this issues Don!

It's certainly clearly problematic if this thing throws because saved state is no longer valid! I also like how you are resolving back to the default state to get back to a good state 👍 But I realised that assumes the default state respects the constraints, and parseMappings() is used both to set up the initial default state and to handle changing the state.

I wonder if we should only be this lenient in the latter case? It seems wrong to allow apps to set up a Grid where the defaults are always wrong - especially if we expect loading the defaults to resolve the issue. Maybe we could add a second strict parameter to parseMappings(), and conditionally throw or warn based on that?

remove(mapping, it => offenders.includes(it.field));
}

if ((zone == 'tl' || zone == 'tr') && isEmpty(mapping)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! But I think we want to do this outside of the !isEmpty(limit.only) condition.

(I know enforcing only is currently the only place where we remove mappings, but I think the intent is clearer if we always do this as the final check of parseMappings)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great note Tom. I considered the same, but apparently made the wrong choice ;)

});

if (!isEmpty(offenders)) {
remove(mapping, it => offenders.includes(it.field));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set to default again here. Only need to warn for one field and say we're going to the default immediately at that point.

@febbraiod febbraiod marked this pull request as ready for review November 21, 2023 20:43
@febbraiod febbraiod merged commit b97a7f4 into develop Nov 21, 2023
2 checks passed
@febbraiod febbraiod deleted the MoreForgivingZoneGirdModel branch November 21, 2023 22:53
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.

3 participants