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

Properties whose available options change via dependency creates an unresolvable state for users #4465

Open
4 tasks done
joesolly opened this issue Jan 23, 2025 · 4 comments
Labels
feature Is a feature request help wanted

Comments

@joesolly
Copy link

Prerequisites

What theme are you using?

core

Version

5.24.1

Current Behavior

When I create a property dependency and the dependent property is an array with multiple options whose options change based on the dependency, if I start to select options, then switch the dependent field, the formdata does not clear the invalid options.

Expected Behavior

Invalid array options are cleared when the available list of options changes

Steps To Reproduce

Playground Sandbox Link

  1. Create a property with a selectable option, say product type {'fruit', 'dairy'}
  2. Create a dependent property that is an array whose options change, 'fruit' -> 'apple', 'banana' and 'dairy' -> 'milk', 'cheese'
  3. Selecting 'apple' then switching to 'dairy' leaves a user in an uncorrectable state because 'apple' stays in the form data

See the video of me demonstrating it with the Playground Sandbox

Screen.Recording.2025-01-23.at.9.47.20.AM.mov

Environment

- OS:
- Node:
- npm:

Anything else?

No response

@joesolly joesolly added bug needs triage Initial label given, to be assigned correct labels and assigned labels Jan 23, 2025
@joesolly
Copy link
Author

This might be related to #3894

@heath-freenome heath-freenome added help wanted feature Is a feature request and removed needs triage Initial label given, to be assigned correct labels and assigned bug labels Jan 24, 2025
@heath-freenome
Copy link
Member

@joesolly It definitely seems related. Are you interesting in figuring out how to fix it by adding a new feature?

@joesolly
Copy link
Author

@joesolly It definitely seems related. Are you interesting in figuring out how to fix it by adding a new feature?

@heath-freenome I'd be willing to take a stab at it if you have an idea of where to point me. I'm currently working around this by hardcoding clearing the formdata when the particular field changes.

@heath-freenome
Copy link
Member

heath-freenome commented Jan 24, 2025

@joesolly The culprit is likely the sanitizeDataForNewSchema() function in the @rjsf/utils package. It currently does not have logic for dealing with anyOf/oneOf in either an object or and array>items situation. It's also possible that it needs to deal with dependencies as well (although it does use retrieveSchema which theoretically handles dependencies for us). We'd love help expanding it's capabilities.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is a feature request help wanted
Projects
None yet
Development

No branches or pull requests

2 participants