-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
Error when loading in JSON saving and removing last rule in group #190
Comments
Is this issue marked won't fix because For me it seemed reasonable to use JsonTree in my React state because it is easier to interact with, but it looks like |
Yes. |
@qurben FYI I ended up adding a work around in my own code to change the query builder's behavior so that a group disappears when the last item is deleted or dragged out instead of maintaining the empty group. I needed to save my state in Json Rules Engine (https://github.com/CacheControl/json-rules-engine) format and it was way easier to convert to Rules Engine format from the json tree. Ignoring my Json Rules Engine conversion, I am recursively stripping out empty groups after To save: To load: Not an ideal solution for several reasons but it worked for my use case. |
I worked around this by just using ImmutableTree as the state. Which requires some extra logic when other parts use the tree, but it works. |
Fix: |
Describe the bug
When I save and load value from the json version saved in state, instead of the Immutable Tree version, I am seeing an error when a group is left empty. Most of the time this works fine and there are no problems, but if a group is left empty either by dragging or deleting an error is thrown.
Apologies if I am missing something obvious, or if there is some reason this should never work, but saw the same problem both in my own code and when I modified and ran
demo.tsx
.To Reproduce
demo.tsx
to look like version included inAdditional Context
below.npm run examples
from awesome query builder repo.Expected behavior
Additional context
Here is what my modified version of
demo.tsx
looks like:The text was updated successfully, but these errors were encountered: