Commit eb77ce9
authored
Fix 3367 so that multiple near simultaneous changes don't lose data (rjsf-team#4721)
* Fix 3367 so that multiple near simultaneous changes don't lose data
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
* - Fixed up a few little things
* - More minor fixes1 parent afdeb70 commit eb77ce9
File tree
34 files changed
+656
-297
lines changed- docs
- packages
- core
- src/components
- fields
- widgets
- test
- daisyui/src/widgets
- DateTimeWidget
- DateWidget
- docs/docs
- advanced-customization
- migration-guides
- mantine/src/widgets/DateTime
- playground/src
- components
- samples
- utils/src
34 files changed
+656
-297
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| 69 | + | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
| |||
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
275 | 290 | | |
276 | 291 | | |
277 | 292 | | |
| |||
283 | 298 | | |
284 | 299 | | |
285 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
286 | 305 | | |
287 | 306 | | |
288 | 307 | | |
| |||
539 | 558 | | |
540 | 559 | | |
541 | 560 | | |
542 | | - | |
543 | | - | |
| 561 | + | |
544 | 562 | | |
545 | 563 | | |
546 | 564 | | |
| |||
550 | 568 | | |
551 | 569 | | |
552 | 570 | | |
553 | | - | |
| 571 | + | |
| 572 | + | |
554 | 573 | | |
555 | 574 | | |
556 | 575 | | |
| |||
655 | 674 | | |
656 | 675 | | |
657 | 676 | | |
658 | | - | |
659 | | - | |
| 677 | + | |
660 | 678 | | |
661 | 679 | | |
662 | | - | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
663 | 687 | | |
664 | 688 | | |
665 | 689 | | |
| |||
705 | 729 | | |
706 | 730 | | |
707 | 731 | | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
| 732 | + | |
| 733 | + | |
714 | 734 | | |
715 | | - | |
716 | | - | |
717 | | - | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
718 | 755 | | |
719 | | - | |
720 | | - | |
721 | | - | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
722 | 764 | | |
| 765 | + | |
723 | 766 | | |
| 767 | + | |
724 | 768 | | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
725 | 773 | | |
726 | 774 | | |
727 | 775 | | |
| |||
738 | 786 | | |
739 | 787 | | |
740 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
741 | 796 | | |
742 | 797 | | |
743 | 798 | | |
| |||
762 | 817 | | |
763 | 818 | | |
764 | 819 | | |
| 820 | + | |
765 | 821 | | |
766 | 822 | | |
767 | 823 | | |
| |||
771 | 827 | | |
772 | 828 | | |
773 | 829 | | |
774 | | - | |
775 | | - | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
776 | 839 | | |
777 | 840 | | |
778 | 841 | | |
| |||
1029 | 1092 | | |
1030 | 1093 | | |
1031 | 1094 | | |
1032 | | - | |
| 1095 | + | |
1033 | 1096 | | |
1034 | 1097 | | |
1035 | 1098 | | |
| |||
1082 | 1145 | | |
1083 | 1146 | | |
1084 | 1147 | | |
1085 | | - | |
| 1148 | + | |
1086 | 1149 | | |
1087 | 1150 | | |
1088 | 1151 | | |
| |||
0 commit comments