Skip to content

Conversation

heath-freenome
Copy link
Member

Reasons for making this change

Fixes #3367 by changing how the onChange callback works so that it queues up changes at the field level rather than the whole formData level

  • Updated package*.json to install is-ci and changed prepare to be "is-ci || husky"
  • Updated .eslintrc.json to add "react-hooks/exhaustive-deps": "error", so that we use hook dependencies properly
    • Updated @rjsf/core's CheckboxesWidget, and playground's Header and Playground to fix the dependencies
    • Updated @rjsf/daisyui's DateTimeWidget and DateWidget to fix the dependencies
  • Updated docs/index.md to remove the details about older versions since we have them now
  • Updated playground's samples to fix a few issues in them
    • Updated customArray.tsx to fix the ArrayFieldTemplate to use the correct buttonsProps prop on the element
    • Updated customFieldAnyOf.tsx to make it properly use the theme components by switching to FieldTemplate, StringField and NumberField
  • Updated @rjsf/core and @rjsf/mantine theme's AltDateWidget to fix a bug with how the clear button works with the updated onChange process
  • Updated @rjsf/utils to make a BREAKING CHANGE to the FieldProps.onChange prop to inject a path?: (number | string)[] before the ErrorSchema parameter
  • Updated @rjsf/core to fix Custom Field onChange not working #3367 as follows:
    • Updated BooleanField and StringField to add an onWidgetChange intermediate callback to insert [] into the field's onChange() callback
    • Updated ArrayField and ObjectField to inject the new path parameter as needed
      • Also, made the main onChange handler pass the value rather than building the whole formData and errorSchema
    • Updated LayoutGridField to update onFieldChange() to add the path on the handler and use the dottedPath to pass down the real path to onChange
    • Updated LayoutMultiSchemaField, MultiSchemaField, NullField and SchemaField to add the path on the handlers and passing to onChange
    • Updated Form to refactor the onChange handler to support queuing changes into a new pendingChanges[] array and calling the new processPendingChange() function
      • The processPendingChange() function takes the newValue and the path and sets that value into the formData and the newErrorSchema into the errorSchema
    • Updated the custom fields in the tests for ArrayField, ObjectField and StringField tests for the new onChange handling mechanism
    • Updated the tests for LayoutGridField and LayoutMultiSchemaField to deal with the new onChange handling mechanism
    • Updated the tests for Form to add testing of near simultaneous changes to verify the fix works
  • Updated the custom-widgets-fields.md documentation to reflect the changes to the onChange handling
  • Updated the v6.x upgrade guide.md to document the breaking changes around the FieldProps.onChange handling
  • Updated the CHANGELOG.md file accordingly

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && 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

Fixes rjsf-team#3367 by changing how the `onChange` callback works so that it queues up changes at the field level rather than the whole formData level
- Updated `package*.json` to install `is-ci` and changed `prepare` to be `"is-ci || husky"`
- Updated `.eslintrc.json` to add `"react-hooks/exhaustive-deps": "error",` so that we use hook dependencies properly
  - Updated `@rjsf/core`'s `CheckboxesWidget`, and `playground`'s `Header` and `Playground` to fix the dependencies
  - Updated `@rjsf/daisyui`'s `DateTimeWidget` and `DateWidget` to fix the dependencies
- Updated `docs/index.md` to remove the details about older versions since we have them now
- Updated `playground`'s samples to fix a few issues in them
  - Updated `customArray.tsx` to fix the `ArrayFieldTemplate` to use the correct `buttonsProps` prop on the `element`
  - Updated `customFieldAnyOf.tsx` to make it properly use the theme components by switching to `FieldTemplate`, `StringField` and `NumberField`
- Updated `@rjsf/core` and `@rjsf/mantine` theme's `AltDateWidget` to fix a bug with how the clear button works with the updated `onChange` process
- Updated `@rjsf/utils` to make a BREAKING CHANGE to the `FieldProps.onChange` prop to inject a `path?: (number | string)[]` before the `ErrorSchema` parameter
- Updated `@rjsf/core` to fix rjsf-team#3367 as follows:
  - Updated `BooleanField` and `StringField` to add an `onWidgetChange` intermediate callback to insert `[]` into the field's `onChange()` callback
  - Updated `ArrayField` and `ObjectField` to inject the new `path` parameter as needed
     - Also, made the main `onChange` handler pass the value rather than building the whole `formData` and `errorSchema`
  - Updated `LayoutGridField` to update `onFieldChange()` to add the `path` on the handler and use the `dottedPath` to pass down the real `path` to `onChange`
  - Updated `LayoutMultiSchemaField`, `MultiSchemaField`, `NullField` and `SchemaField` to add the `path` on the handlers and passing to `onChange`
  - Updated `Form` to refactor the `onChange` handler to support queuing changes into a new `pendingChanges[]` array and calling the new `processPendingChange()` function
    - The `processPendingChange()` function takes the `newValue` and the `path` and sets that value into the `formData` and the `newErrorSchema` into the `errorSchema`
  - Updated the custom fields in the tests for `ArrayField`, `ObjectField` and `StringField` tests for the new `onChange` handling mechanism
  - Updated the tests for `LayoutGridField` and `LayoutMultiSchemaField` to deal with the new `onChange` handling mechanism
  - Updated the tests for `Form` to add testing of near simultaneous changes to verify the fix works
- Updated the `custom-widgets-fields.md` documentation to reflect the changes to the `onChange` handling
- Updated the `v6.x upgrade guide.md` to document the breaking changes around the `FieldProps.onChange` handling
- Updated the `CHANGELOG.md` file accordingly
@heath-freenome heath-freenome merged commit eb77ce9 into rjsf-team:main Aug 18, 2025
4 checks passed
@heath-freenome heath-freenome deleted the fix-3367 branch August 18, 2025 16:35
@Fronix Fronix mentioned this pull request Aug 26, 2025
8 tasks
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.

Custom Field onChange not working

2 participants