Skip to content

Commit 93669b7

Browse files
Fix hidden widget in several themes and SelectWidget in bootstrap-4 (#3036)
* Fix hidden widget in several themes and SelectWidget in bootstrap-4 - Updated the `FieldTemplate` in `chakra-ui`, `material-ui`, `mui` and `semantic-ui` to properly implement the hidden field - Updated `SelectWidget` in `bootstrap-4` to fix missing `htmlFor` and the `disabled` state when `readonly` - Updated snapshots to verify fixes - Also removed the `test:update` script from `core`, `utils` and `validator-ajv6` because they are useless * - Responded to reviewer feedback
1 parent 0d5be92 commit 93669b7

File tree

14 files changed

+65
-34
lines changed

14 files changed

+65
-34
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ const SelectWidget = ({
4141

4242
return (
4343
<Form.Group>
44-
<Form.Label className={rawErrors.length > 0 ? "text-danger" : ""}>
44+
<Form.Label
45+
className={rawErrors.length > 0 ? "text-danger" : ""}
46+
htmlFor={id}
47+
>
4548
{label || schema.title}
4649
{(label || schema.title) && required ? "*" : null}
4750
</Form.Label>
@@ -52,8 +55,7 @@ const SelectWidget = ({
5255
value={typeof value === "undefined" ? emptyValue : value}
5356
required={required}
5457
multiple={multiple}
55-
disabled={disabled}
56-
readOnly={readonly}
58+
disabled={disabled || readonly}
5759
autoFocus={autofocus}
5860
className={rawErrors.length > 0 ? "is-invalid" : ""}
5961
onBlur={

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ exports[`array fields checkboxes 1`] = `
515515
>
516516
<label
517517
className="form-label"
518+
htmlFor="root"
518519
/>
519520
<select
520521
autoFocus={false}
@@ -525,7 +526,6 @@ exports[`array fields checkboxes 1`] = `
525526
onBlur={[Function]}
526527
onChange={[Function]}
527528
onFocus={[Function]}
528-
readOnly={false}
529529
required={false}
530530
value={Array []}
531531
>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ exports[`single fields select field 1`] = `
919919
>
920920
<label
921921
className="form-label"
922+
htmlFor="root"
922923
/>
923924
<select
924925
autoFocus={false}
@@ -928,7 +929,6 @@ exports[`single fields select field 1`] = `
928929
onBlur={[Function]}
929930
onChange={[Function]}
930931
onFocus={[Function]}
931-
readOnly={false}
932932
value=""
933933
>
934934
<option

packages/chakra-ui/src/FieldTemplate/FieldTemplate.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const FieldTemplate = (props: FieldTemplateProps) => {
3333
} = props;
3434

3535
if (hidden) {
36-
return <>{children}</>;
36+
return <div style={{ display: "none" }}>{children}</div>;
3737
}
3838

3939
return (

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -1242,11 +1242,19 @@ exports[`single fields hidden field 1`] = `
12421242
<div
12431243
className="emotion-1"
12441244
>
1245-
<input
1246-
id="root_my-field"
1247-
type="hidden"
1248-
value=""
1249-
/>
1245+
<div
1246+
style={
1247+
Object {
1248+
"display": "none",
1249+
}
1250+
}
1251+
>
1252+
<input
1253+
id="root_my-field"
1254+
type="hidden"
1255+
value=""
1256+
/>
1257+
</div>
12501258
</div>
12511259
</div>
12521260
</div>

packages/core/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"start": "dts watch",
1313
"test": "dts test",
1414
"test:watch": "dts test --watch",
15-
"test:update": "dts test --u",
1615
"test-coverage": "dts test --coverage"
1716
},
1817
"lint-staged": {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const FieldTemplate = ({
2727
registry,
2828
}: FieldTemplateProps) => {
2929
if (hidden) {
30-
return children;
30+
return <div style={{ display: "none" }}>{children}</div>;
3131
}
3232
return (
3333
<WrapIfAdditional

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,19 @@ exports[`single fields hidden field 1`] = `
899899
}
900900
}
901901
>
902-
<input
903-
id="root_my-field"
904-
type="hidden"
905-
value=""
906-
/>
902+
<div
903+
style={
904+
Object {
905+
"display": "none",
906+
}
907+
}
908+
>
909+
<input
910+
id="root_my-field"
911+
type="hidden"
912+
value=""
913+
/>
914+
</div>
907915
</div>
908916
</div>
909917
</div>

packages/mui/src/FieldTemplate/FieldTemplate.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const FieldTemplate = ({
2727
registry,
2828
}: FieldTemplateProps) => {
2929
if (hidden) {
30-
return children;
30+
return <div style={{ display: "none" }}>{children}</div>;
3131
}
3232
return (
3333
<WrapIfAdditional

packages/mui/test/__snapshots__/Form.test.tsx.snap

+13-5
Original file line numberDiff line numberDiff line change
@@ -3815,11 +3815,19 @@ exports[`single fields hidden field 1`] = `
38153815
}
38163816
}
38173817
>
3818-
<input
3819-
id="root_my-field"
3820-
type="hidden"
3821-
value=""
3822-
/>
3818+
<div
3819+
style={
3820+
Object {
3821+
"display": "none",
3822+
}
3823+
}
3824+
>
3825+
<input
3826+
id="root_my-field"
3827+
type="hidden"
3828+
value=""
3829+
/>
3830+
</div>
38233831
</div>
38243832
</div>
38253833
</div>

packages/semantic-ui/src/FieldTemplate/FieldTemplate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function FieldTemplate({
3333
);
3434

3535
if (hidden) {
36-
return children;
36+
return <div style={{ display: "none" }}>{children}</div>;
3737
}
3838

3939
return (

packages/semantic-ui/test/__snapshots__/Form.test.js.snap

+13-5
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,19 @@ exports[`single fields hidden field 1`] = `
684684
className="grouped equal width fields"
685685
>
686686
687-
<input
688-
id="root_my-field"
689-
type="hidden"
690-
value=""
691-
/>
687+
<div
688+
style={
689+
Object {
690+
"display": "none",
691+
}
692+
}
693+
>
694+
<input
695+
id="root_my-field"
696+
type="hidden"
697+
value=""
698+
/>
699+
</div>
692700
</div>
693701
</div>
694702
<button

packages/utils/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
1919
"lint": "eslint src test",
2020
"precommit": "lint-staged",
21-
"test": "dts test",
22-
"test:update": "dts test --u"
21+
"test": "dts test"
2322
},
2423
"lint-staged": {
2524
"{src,test}/**/*.ts?(x)": [

packages/validator-ajv6/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
2020
"lint": "eslint src test",
2121
"precommit": "lint-staged",
22-
"test": "dts test",
23-
"test:update": "dts test --u"
22+
"test": "dts test"
2423
},
2524
"lint-staged": {
2625
"{src,test}/**/*.ts?(x)": [

0 commit comments

Comments
 (0)