Skip to content

Commit 2d90bd2

Browse files
authored
[rjsf-teamGH-2088][material-ui] fix: Text inputs render with invalid attribute (rjsf-team#2215)
fix rjsf-team#2088
1 parent 744d704 commit 2d90bd2

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

packages/material-ui/src/TextWidget/TextWidget.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const TextWidget = ({
4444
uiSchema
4545
/* TODO: , rootSchema */
4646
);
47+
const inputType = (type || schema.type) === 'string' ? 'text' : `${type || schema.type}`
4748

4849
return (
4950
<TextField
@@ -52,7 +53,7 @@ const TextWidget = ({
5253
autoFocus={autofocus}
5354
required={required}
5455
disabled={disabled || readonly}
55-
type={type || (schema.type as string)}
56+
type={inputType as string}
5657
value={value || value === 0 ? value : ""}
5758
error={rawErrors.length > 0}
5859
onChange={_onChange}

packages/material-ui/test/__snapshots__/Array.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ exports[`array fields fixed array 1`] = `
295295
onFocus={[Function]}
296296
placeholder=""
297297
required={true}
298-
type="string"
298+
type="text"
299299
value=""
300300
/>
301301
</div>

packages/material-ui/test/__snapshots__/Form.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ exports[`single fields hidden label 1`] = `
870870
onFocus={[Function]}
871871
placeholder=""
872872
required={false}
873-
type="string"
873+
type="text"
874874
value=""
875875
/>
876876
</div>
@@ -1861,7 +1861,7 @@ exports[`single fields string field regular 1`] = `
18611861
onFocus={[Function]}
18621862
placeholder=""
18631863
required={false}
1864-
type="string"
1864+
type="text"
18651865
value=""
18661866
/>
18671867
</div>
@@ -1972,7 +1972,7 @@ exports[`single fields string field with placeholder 1`] = `
19721972
onFocus={[Function]}
19731973
placeholder="placeholder"
19741974
required={false}
1975-
type="string"
1975+
type="text"
19761976
value=""
19771977
/>
19781978
</div>

packages/material-ui/test/__snapshots__/Object.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ exports[`object fields additionalProperties 1`] = `
137137
onFocus={[Function]}
138138
placeholder=""
139139
required={false}
140-
type="string"
140+
type="text"
141141
value="foo"
142142
/>
143143
</div>
@@ -381,7 +381,7 @@ exports[`object fields object 1`] = `
381381
onFocus={[Function]}
382382
placeholder=""
383383
required={false}
384-
type="string"
384+
type="text"
385385
value=""
386386
/>
387387
</div>

0 commit comments

Comments
 (0)