Skip to content

Commit 159c165

Browse files
committed
misc: update checkbox widget ui
1 parent edea993 commit 159c165

File tree

2 files changed

+12
-31
lines changed

2 files changed

+12
-31
lines changed

packages/jsonschema-page/src/Widgets/CheckboxWidget.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,18 @@ export default function CheckboxWidget<
8080
const _onBlur = ({ target: { value } }: FocusEvent<HTMLButtonElement>) => onBlur(id, value);
8181
const _onFocus = ({ target: { value } }: FocusEvent<HTMLButtonElement>) => onFocus(id, value);
8282
const description = options.description ?? schema.description;
83-
let labelNode: ReactNode = labelValue(label, hideLabel, false);
84-
if (!hideLabel && !!description) {
85-
labelNode = (
86-
<StyledSwitchLabelWrapper>
87-
{labelNode}
88-
<DescriptionFieldTemplate
89-
id={descriptionId<T>(id)}
90-
description={description}
91-
schema={schema}
92-
uiSchema={uiSchema}
93-
registry={registry}
94-
/>
95-
</StyledSwitchLabelWrapper>
96-
);
97-
}
83+
const labelNode: ReactNode = (!hideLabel && !!description) ? (
84+
<StyledSwitchLabelWrapper>
85+
{labelValue(label, hideLabel, false)}
86+
<DescriptionFieldTemplate
87+
id={descriptionId<T>(id)}
88+
description={description}
89+
schema={schema}
90+
uiSchema={uiSchema}
91+
registry={registry}
92+
/>
93+
</StyledSwitchLabelWrapper>
94+
) :labelValue(label, hideLabel, false);
9895
return (
9996
<>
10097
<SwitchContainer>

packages/jsonschema-page/src/__stories__/Widgets.stories.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -367,25 +367,9 @@ export const BooleanToggleWidget: Story = {
367367
required: ['requiredToggle'],
368368
},
369369
uiSchema: {
370-
basicToggle: {
371-
'ui:widget': 'checkbox',
372-
},
373-
defaultTrue: {
374-
'ui:widget': 'checkbox',
375-
},
376370
requiredToggle: {
377-
'ui:widget': 'checkbox',
378371
'ui:help': 'This field is required',
379372
},
380-
consentToggle: {
381-
'ui:widget': 'checkbox',
382-
},
383-
privacyToggle: {
384-
'ui:widget': 'checkbox',
385-
},
386-
notificationToggle: {
387-
'ui:widget': 'checkbox',
388-
},
389373
},
390374
formData: {
391375
basicToggle: false,

0 commit comments

Comments
 (0)