Skip to content

Commit 9fd6f7c

Browse files
Fix: Revert part of fix for rjsf-team#1654 that was causing rjsf-team#3412 (rjsf-team#3414)
Fixes: rjsf-team#3412 by reverting the last change made to `getSchemaType()` The type inference from `anyOf`/`oneOf` that was added to fix rjsf-team#1654 actually caused a worse bug, and without it the inference now happens properly due to other fixes somehow - In `@rjsf/utils`, reverted the type inference from `anyOf`/`oneOf` - Updated the `CHANGELOG.md` accordingly
1 parent 7237051 commit 9fd6f7c

File tree

3 files changed

+1
-24
lines changed

3 files changed

+1
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ should change the heading of the (upcoming) version to include a major version b
4545
- Added `enumOptionsIndexForValue()`, `enumOptionsIsSelected()`, `enumOptionsValueForIndex()` functions to support fixing [#1494](https://github.com/rjsf-team/react-jsonschema-form/issues/1494)
4646
- Updated `enumOptionsDeselectValue()`, `enumOptionsSelectValue()` and `optionId()` to use indexes instead of values
4747
- Deleted the `processSelectValue()` that was added in the beta and is no longer needed
48+
- Updated `getSchemaType()` to remove the inference of type from `anyOf`/`oneOf`, fixing [#3412](https://github.com/rjsf-team/react-jsonschema-form/issues/3412)
4849

4950
## Dev / docs / playground
5051
- Updated the `utility-functions` documentation for the new and updated methods mentioned above, as well as deleting the documentation for `processSelectValue()`

packages/utils/src/getSchemaType.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ export default function getSchemaType<S extends StrictRJSFSchema = RJSFSchema>(
2929
return "object";
3030
}
3131

32-
if (!type && Array.isArray(schema.oneOf) && schema.oneOf.length) {
33-
return getSchemaType<S>(schema.oneOf[0] as S);
34-
}
35-
36-
if (!type && Array.isArray(schema.anyOf) && schema.anyOf.length) {
37-
return getSchemaType<S>(schema.anyOf[0] as S);
38-
}
39-
4032
if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
4133
type = type.find((type) => type !== "null");
4234
}

packages/utils/test/getSchemaType.test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ const cases: { schema: object; expected: string | undefined }[] = [
6161
schema: { enum: ["foo"] },
6262
expected: "string",
6363
},
64-
{
65-
schema: { oneOf: [] },
66-
expected: undefined,
67-
},
68-
{
69-
schema: { oneOf: [{ type: "string" }] },
70-
expected: "string",
71-
},
72-
{
73-
schema: { anyOf: [] },
74-
expected: undefined,
75-
},
76-
{
77-
schema: { anyOf: [{ type: "number" }] },
78-
expected: "number",
79-
},
8064
{
8165
schema: {},
8266
expected: undefined,

0 commit comments

Comments
 (0)