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

OnChange specific field #2768

Closed
1 of 2 tasks
CarlFMateus opened this issue Mar 16, 2022 · 2 comments · Fixed by #3173
Closed
1 of 2 tasks

OnChange specific field #2768

CarlFMateus opened this issue Mar 16, 2022 · 2 comments · Fixed by #3173
Labels
p1 Important to fix soon question

Comments

@CarlFMateus
Copy link

CarlFMateus commented Mar 16, 2022

Hello,

Prerequisites

  • I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Is there a way to know with the onChange callback, which field has been updated ?
This is taken from the following issue #981

This is to know if they found any solution for this type of requirement.

Thank you.

@shubham-malpani
Copy link

I'm also facing same issue. Any solutions to this?

@heath-freenome heath-freenome added the p1 Important to fix soon label Sep 30, 2022
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 3, 2022
- In @rjsf/utils, updated the `FieldProps` type for `onChange` to add an optional `id: string` parameter, making `onChange` for `FieldTemplateProps` use `FieldProps` definition
- In @rjsf/core, updated the library to support returning an optional second parameter, `id: string`, to the `onChange()` prop on `Form` as follows:
  - Updated the `Form.onChange()` callback handler passed to all fields to take an optional third parameter, `id: string`, passing it out to the `onChange()` prop call
  - Updated `ArrayField` to make the callback returned from the `onChangeForIndex()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `MultiSchemaField` to make the `onOptionChange()` method pass along the `this.getFieldId()` value to the `props.onChange()` handler
    - Refactored the `id` logic for the select widget used in the `MultiSchemaField` into the `getFieldId()` method
  - Updated `ObjectField` to make the callback returned from the `onPropertyChange()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `SchemaField` to add a new `handleFieldComponentChange()` callback that ensures that an `id` is passed up the `onChange` callback chain
    - Updated the render of the `FieldComponent` to pass the `handleFieldComponentChange()` as the `onChange` handler
- In @rjsf/playground, updated the `onFormDataChange` handler to log the `id` of the changed field if it is provided
- Updated the `form-props.md` documentation to describe the new `id` parameter that may be returned
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 3, 2022
- In @rjsf/utils, updated the `FieldProps` type for `onChange` to add an optional `id: string` parameter, making `onChange` for `FieldTemplateProps` use `FieldProps` definition
- In @rjsf/core, updated the library to support returning an optional second parameter, `id: string`, to the `onChange()` prop on `Form` as follows:
  - Updated the `Form.onChange()` callback handler passed to all fields to take an optional third parameter, `id: string`, passing it out to the `onChange()` prop call
  - Updated `ArrayField` to make the callback returned from the `onChangeForIndex()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `MultiSchemaField` to make the `onOptionChange()` method pass along the `this.getFieldId()` value to the `props.onChange()` handler
    - Refactored the `id` logic for the select widget used in the `MultiSchemaField` into the `getFieldId()` method
  - Updated `ObjectField` to make the callback returned from the `onPropertyChange()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `SchemaField` to add a new `handleFieldComponentChange()` callback that ensures that an `id` is passed up the `onChange` callback chain
    - Updated the render of the `FieldComponent` to pass the `handleFieldComponentChange()` as the `onChange` handler
  - Updated all of the tests to check for the `id` in those situations when it is passed back
- In @rjsf/playground, updated the `onFormDataChange` handler to log the `id` of the changed field if it is provided
- Updated the `form-props.md` documentation to describe the new `id` parameter that may be returned
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 3, 2022
- In @rjsf/utils, updated the `FieldProps` type for `onChange` to add an optional `id: string` parameter, making `onChange` for `FieldTemplateProps` use `FieldProps` definition
- In @rjsf/core, updated the library to support returning an optional second parameter, `id: string`, to the `onChange()` prop on `Form` as follows:
  - Updated the `Form.onChange()` callback handler passed to all fields to take an optional third parameter, `id: string`, passing it out to the `onChange()` prop call
  - Updated `ArrayField` to make the callback returned from the `onChangeForIndex()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `MultiSchemaField` to make the `onOptionChange()` method pass along the `this.getFieldId()` value to the `props.onChange()` handler
    - Refactored the `id` logic for the select widget used in the `MultiSchemaField` into the `getFieldId()` method
  - Updated `ObjectField` to make the callback returned from the `onPropertyChange()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `SchemaField` to add a new `handleFieldComponentChange()` callback that ensures that an `id` is passed up the `onChange` callback chain
    - Updated the render of the `FieldComponent` to pass the `handleFieldComponentChange()` as the `onChange` handler
  - Updated all of the tests to check for the `id` in those situations when it is passed back
- In @rjsf/playground, updated the `onFormDataChange` handler to log the `id` of the changed field if it is provided
- Updated the `form-props.md` documentation to describe the new `id` parameter that may be returned
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit that referenced this issue Oct 3, 2022
- In @rjsf/utils, updated the `FieldProps` type for `onChange` to add an optional `id: string` parameter, making `onChange` for `FieldTemplateProps` use `FieldProps` definition
- In @rjsf/core, updated the library to support returning an optional second parameter, `id: string`, to the `onChange()` prop on `Form` as follows:
  - Updated the `Form.onChange()` callback handler passed to all fields to take an optional third parameter, `id: string`, passing it out to the `onChange()` prop call
  - Updated `ArrayField` to make the callback returned from the `onChangeForIndex()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `MultiSchemaField` to make the `onOptionChange()` method pass along the `this.getFieldId()` value to the `props.onChange()` handler
    - Refactored the `id` logic for the select widget used in the `MultiSchemaField` into the `getFieldId()` method
  - Updated `ObjectField` to make the callback returned from the `onPropertyChange()` method take the additional `id` parameter and pass it along to the `props.onChange()` handler
  - Updated `SchemaField` to add a new `handleFieldComponentChange()` callback that ensures that an `id` is passed up the `onChange` callback chain
    - Updated the render of the `FieldComponent` to pass the `handleFieldComponentChange()` as the `onChange` handler
  - Updated all of the tests to check for the `id` in those situations when it is passed back
- In @rjsf/playground, updated the `onFormDataChange` handler to log the `id` of the changed field if it is provided
- Updated the `form-props.md` documentation to describe the new `id` parameter that may be returned
- Updated the `CHANGELOG.md` accordingly
@v1talii-dev
Copy link

How to get the object of the sub-scheme in which it is located by id?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1 Important to fix soon question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants