fix: "Checkbox" custom field throws error (#14339)
* fix: "Checkbox" custom field throws error * Add e2e * Self review feedback * Fix typo --------- Co-authored-by: Hariom <[email protected]>
This commit is contained in:
1 parent
a597defd03
commit
beee545568
3 files changed
+61
-4
No files matched your search
@@ -489,10 +489,11 @@ export const Components: Record<FieldType, Component> = {
|
||||
},
|
||||
boolean: {
|
||||
propsType: propsTypes.boolean,
|
||||
factory: ({ readOnly, label, value, setValue }) => {
|
||||
factory: ({ readOnly, name, label, value, setValue }) => {
|
||||
return (
|
||||
<div className="flex">
|
||||
<CheckboxField
|
||||
name={name}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
setValue(true);
|
||||
|
||||
@@ -120,6 +120,13 @@ export const FormBuilder = function FormBuilder({
|
||||
: field.getOptionsAt
|
||||
? dataStore.options[field.getOptionsAt as keyof typeof dataStore]
|
||||
: [];
|
||||
|
||||
// Note: We recently started calling getAndUpdateNormalizedValues in the FormBuilder. It was supposed to be called only on booking pages earlier.
|
||||
// Due to this we have to meet some strict requirements like of labelAsSafeHtml.
|
||||
if (fieldsThatSupportLabelAsSafeHtml.includes(field.type)) {
|
||||
field = { ...field, labelAsSafeHtml: markdownToSafeHTML(field.label ?? "") };
|
||||
}
|
||||
|
||||
const { hidden } = getAndUpdateNormalizedValues({ ...field, options }, t);
|
||||
if (field.hideWhenJustOneOption && (hidden || !options?.length)) {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user