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

Skip populate function proposal in Experimental_ArrayMinItems #4121

Merged
merged 8 commits into from
Mar 21, 2024

Conversation

MarekBodingerBA
Copy link
Contributor

@MarekBodingerBA MarekBodingerBA commented Mar 8, 2024

Reasons for making this change

As we use our custom implementation of file upload, we would like to have case-by-case method how to control population of arrays in Experimental_ArrayMinItems (and there might be need from others with advanced usages).

Our files implementation yields this schema:
https://github.com/bratislava/konto.bratislava.sk/blob/8ce56b7fa4a62c7dd67351b617ba5ad13bc363b8/next/schema-generator/generator/functions.ts#L372

We would like to use { populate: 'requiredOnly' }. It works fine for our multiselects and checkbox group, as they are handled by the isMultiSelect condition, but it populates our files array with [null]. Therefore I would like to implement skipPopulate (name is up for consideration) function that would allow us to have a custom logic to skip population similar to what isMultiSelect does.

As a temporary solution, we have our own fork that allows us to add overrideArrayMinItemsBehaviour to schema, but this might be better and more scalable solution.

What do you think? Should I continue with this idea?

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@heath-freenome
Copy link
Member

@MarekBodingerBA I like the concept. The name skipPopulate might be confusing, especially as someone could think it is a boolean. How does the name computeSkipPopulate sound? Please make sure to update documentation and provide an example in the playground. And maintain 100% test coverage for these changes. And finally, update the CHANGELOG.md under the 5.18.0 section. If you can get this in within the next week we can release right afterwards

@MarekBodingerBA
Copy link
Contributor Author

Perfect, that all makes sense!

However, how should I proceed with a playground example? People should provide their own code. I am not sure I should add code input to the playground.

@heath-freenome
Copy link
Member

Perfect, that all makes sense!

However, how should I proceed with a playground example? People should provide their own code. I am not sure I should add code input to the playground.

Great question! Thinking about it more, this isn't a toggle on situation like the rest of the experimental options. So maybe a playground example just doesn't make sense.

… custom logic to skip populating arrays with default values
@MarekBodingerBA MarekBodingerBA marked this pull request as ready for review March 9, 2024 11:32
@MarekBodingerBA
Copy link
Contributor Author

Implemented as you requested, feel free to give a feedback.

packages/utils/src/types.ts Outdated Show resolved Hide resolved
packages/docs/docs/api-reference/form-props.md Outdated Show resolved Hide resolved
@heath-freenome
Copy link
Member

@MarekBodinger Great work... I've added a few suggetions for documentation changes. Also, can you rebase and resolve conflicts

MarekBodingerBA and others added 4 commits March 21, 2024 18:36
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
@MarekBodingerBA
Copy link
Contributor Author

@MarekBodinger Great work... I've added a few suggetions for documentation changes. Also, can you rebase and resolve conflicts

Thank you, I committed the suggestions and merged main.

@heath-freenome heath-freenome merged commit baffbf1 into rjsf-team:main Mar 21, 2024
4 checks passed
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

3 participants