Skip to content

Commit 3b1acd6

Browse files
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
1 parent 6603e96 commit 3b1acd6

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
@@ -496,6 +496,7 @@ exports[`array fields checkboxes 1`] = `
496496
>
497497
<label
498498
className="form-label"
499+
htmlFor="root"
499500
/>
500501
<select
501502
autoFocus={false}
@@ -506,7 +507,6 @@ exports[`array fields checkboxes 1`] = `
506507
onBlur={[Function]}
507508
onChange={[Function]}
508509
onFocus={[Function]}
509-
readOnly={false}
510510
required={false}
511511
value={Array []}
512512
>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ exports[`single fields select field 1`] = `
844844
>
845845
<label
846846
className="form-label"
847+
htmlFor="root"
847848
/>
848849
<select
849850
autoFocus={false}
@@ -853,7 +854,6 @@ exports[`single fields select field 1`] = `
853854
onBlur={[Function]}
854855
onChange={[Function]}
855856
onFocus={[Function]}
856-
readOnly={false}
857857
value=""
858858
>
859859
<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
@@ -1199,11 +1199,19 @@ exports[`single fields hidden field 1`] = `
11991199
<div
12001200
className="emotion-1"
12011201
>
1202-
<input
1203-
id="root_my-field"
1204-
type="hidden"
1205-
value=""
1206-
/>
1202+
<div
1203+
style={
1204+
Object {
1205+
"display": "none",
1206+
}
1207+
}
1208+
>
1209+
<input
1210+
id="root_my-field"
1211+
type="hidden"
1212+
value=""
1213+
/>
1214+
</div>
12071215
</div>
12081216
</div>
12091217
<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
@@ -856,11 +856,19 @@ exports[`single fields hidden field 1`] = `
856856
}
857857
}
858858
>
859-
<input
860-
id="root_my-field"
861-
type="hidden"
862-
value=""
863-
/>
859+
<div
860+
style={
861+
Object {
862+
"display": "none",
863+
}
864+
}
865+
>
866+
<input
867+
id="root_my-field"
868+
type="hidden"
869+
value=""
870+
/>
871+
</div>
864872
</div>
865873
</div>
866874
<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
@@ -3772,11 +3772,19 @@ exports[`single fields hidden field 1`] = `
37723772
}
37733773
}
37743774
>
3775-
<input
3776-
id="root_my-field"
3777-
type="hidden"
3778-
value=""
3779-
/>
3775+
<div
3776+
style={
3777+
Object {
3778+
"display": "none",
3779+
}
3780+
}
3781+
>
3782+
<input
3783+
id="root_my-field"
3784+
type="hidden"
3785+
value=""
3786+
/>
3787+
</div>
37803788
</div>
37813789
</div>
37823790
<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
@@ -633,11 +633,19 @@ exports[`single fields hidden field 1`] = `
633633
className="grouped equal width fields"
634634
>
635635
636-
<input
637-
id="root_my-field"
638-
type="hidden"
639-
value=""
640-
/>
636+
<div
637+
style={
638+
Object {
639+
"display": "none",
640+
}
641+
}
642+
>
643+
<input
644+
id="root_my-field"
645+
type="hidden"
646+
value=""
647+
/>
648+
</div>
641649
</div>
642650
<button
643651
className="ui primary 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)