Skip to content

Fix hidden widget in several themes and SelectWidget in bootstrap-4 #3036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/bootstrap-4/src/SelectWidget/SelectWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const SelectWidget = ({

return (
<Form.Group>
<Form.Label className={rawErrors.length > 0 ? "text-danger" : ""}>
<Form.Label
className={rawErrors.length > 0 ? "text-danger" : ""}
htmlFor={id}
>
{label || schema.title}
{(label || schema.title) && required ? "*" : null}
</Form.Label>
Expand All @@ -52,8 +55,7 @@ const SelectWidget = ({
value={typeof value === "undefined" ? emptyValue : value}
required={required}
multiple={multiple}
disabled={disabled}
readOnly={readonly}
disabled={disabled || readonly}
autoFocus={autofocus}
className={rawErrors.length > 0 ? "is-invalid" : ""}
onBlur={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ exports[`array fields checkboxes 1`] = `
>
<label
className="form-label"
htmlFor="root"
/>
<select
autoFocus={false}
Expand All @@ -525,7 +526,6 @@ exports[`array fields checkboxes 1`] = `
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
readOnly={false}
required={false}
value={Array []}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/bootstrap-4/test/__snapshots__/Form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ exports[`single fields select field 1`] = `
>
<label
className="form-label"
htmlFor="root"
/>
<select
autoFocus={false}
Expand All @@ -928,7 +929,6 @@ exports[`single fields select field 1`] = `
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
readOnly={false}
value=""
>
<option
Expand Down
2 changes: 1 addition & 1 deletion packages/chakra-ui/src/FieldTemplate/FieldTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const FieldTemplate = (props: FieldTemplateProps) => {
} = props;

if (hidden) {
return <>{children}</>;
return <div style={{ display: "none" }}>{children}</div>;
}

return (
Expand Down
18 changes: 13 additions & 5 deletions packages/chakra-ui/test/__snapshots__/Form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1242,11 +1242,19 @@ exports[`single fields hidden field 1`] = `
<div
className="emotion-1"
>
<input
id="root_my-field"
type="hidden"
value=""
/>
<div
style={
Object {
"display": "none",
}
}
>
<input
id="root_my-field"
type="hidden"
value=""
/>
</div>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"start": "dts watch",
"test": "dts test",
"test:watch": "dts test --watch",
"test:update": "dts test --u",
"test-coverage": "dts test --coverage"
},
"lint-staged": {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/FieldTemplate/FieldTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const FieldTemplate = ({
registry,
}: FieldTemplateProps) => {
if (hidden) {
return children;
return <div style={{ display: "none" }}>{children}</div>;
}
return (
<WrapIfAdditional
Expand Down
18 changes: 13 additions & 5 deletions packages/material-ui/test/__snapshots__/Form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,19 @@ exports[`single fields hidden field 1`] = `
}
}
>
<input
id="root_my-field"
type="hidden"
value=""
/>
<div
style={
Object {
"display": "none",
}
}
>
<input
id="root_my-field"
type="hidden"
value=""
/>
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/mui/src/FieldTemplate/FieldTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const FieldTemplate = ({
registry,
}: FieldTemplateProps) => {
if (hidden) {
return children;
return <div style={{ display: "none" }}>{children}</div>;
}
return (
<WrapIfAdditional
Expand Down
18 changes: 13 additions & 5 deletions packages/mui/test/__snapshots__/Form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3815,11 +3815,19 @@ exports[`single fields hidden field 1`] = `
}
}
>
<input
id="root_my-field"
type="hidden"
value=""
/>
<div
style={
Object {
"display": "none",
}
}
>
<input
id="root_my-field"
type="hidden"
value=""
/>
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/semantic-ui/src/FieldTemplate/FieldTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function FieldTemplate({
);

if (hidden) {
return children;
return <div style={{ display: "none" }}>{children}</div>;
}

return (
Expand Down
18 changes: 13 additions & 5 deletions packages/semantic-ui/test/__snapshots__/Form.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,19 @@ exports[`single fields hidden field 1`] = `
className="grouped equal width fields"
>

<input
id="root_my-field"
type="hidden"
value=""
/>
<div
style={
Object {
"display": "none",
}
}
>
<input
id="root_my-field"
type="hidden"
value=""
/>
</div>
</div>
</div>
<button
Expand Down
3 changes: 1 addition & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
"lint": "eslint src test",
"precommit": "lint-staged",
"test": "dts test",
"test:update": "dts test --u"
"test": "dts test"
},
"lint-staged": {
"{src,test}/**/*.ts?(x)": [
Expand Down
3 changes: 1 addition & 2 deletions packages/validator-ajv6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
"lint": "eslint src test",
"precommit": "lint-staged",
"test": "dts test",
"test:update": "dts test --u"
"test": "dts test"
},
"lint-staged": {
"{src,test}/**/*.ts?(x)": [
Expand Down