Skip to content

Commit 744d704

Browse files
authored
[rjsf-teamGH-2087][bootstrap-4] fix: Text inputs render with invalid attribute (rjsf-team#2216)
fix rjsf-team#2087
1 parent e0ec5ea commit 744d704

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

packages/bootstrap-4/src/TextWidget/TextWidget.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const TextWidget = ({
3434
const _onFocus = ({
3535
target: { value },
3636
}: React.FocusEvent<HTMLInputElement>) => onFocus(id, value);
37-
37+
const inputType = (type || schema.type) === 'string' ? 'text' : `${type || schema.type}`
38+
3839
// const classNames = [rawErrors.length > 0 ? "is-invalid" : "", type === 'file' ? 'custom-file-label': ""]
3940
return (
4041
<Form.Group className="mb-0">
@@ -50,7 +51,7 @@ const TextWidget = ({
5051
readOnly={readonly}
5152
className={rawErrors.length > 0 ? "is-invalid" : ""}
5253
list={schema.examples ? `examples_${id}` : undefined}
53-
type={type || (schema.type as string)}
54+
type={inputType}
5455
value={value || value === 0 ? value : ""}
5556
onChange={_onChange}
5657
onBlur={_onBlur}

packages/bootstrap-4/test/__snapshots__/Array.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ exports[`array fields fixed array 1`] = `
199199
onFocus={[Function]}
200200
readOnly={false}
201201
required={true}
202-
type="string"
202+
type="text"
203203
value=""
204204
/>
205205
</div>

packages/bootstrap-4/test/__snapshots__/Form.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ exports[`single fields string field regular 1`] = `
775775
onChange={[Function]}
776776
onFocus={[Function]}
777777
readOnly={false}
778-
type="string"
778+
type="text"
779779
value=""
780780
/>
781781
</div>
@@ -816,7 +816,7 @@ exports[`single fields string field with placeholder 1`] = `
816816
onChange={[Function]}
817817
onFocus={[Function]}
818818
readOnly={false}
819-
type="string"
819+
type="text"
820820
value=""
821821
/>
822822
</div>

packages/bootstrap-4/test/__snapshots__/Object.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ exports[`object fields object 1`] = `
4545
onFocus={[Function]}
4646
readOnly={false}
4747
required={false}
48-
type="string"
48+
type="text"
4949
value=""
5050
/>
5151
</div>

0 commit comments

Comments
 (0)