Skip to content
Draft
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
2 changes: 1 addition & 1 deletion example/src/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const OnboardingWithProps = ({
options={{
features: ['onboarding_reserves'],
jsonSchemaVersion: {
employment_basic_information: 'latest',
employment_basic_information: 3,
},
jsonSchemaVersionByCountry: {
DEU: {
Expand Down
34 changes: 14 additions & 20 deletions src/components/form/fields/ForcedValueField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,24 @@ export function ForcedValueField({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const titleSanitized = statement?.title
? sanitizeHtml(statement?.title)
: sanitizeHtml(label);
return (
<div>
{statement ? (
<>
{/* if statement?.title is undefined which could be for example belgium contract details form, we need to use the label attribute */}
<p
className={`text-sm RemoteFlows__ForcedValue__Title__${name}`}
dangerouslySetInnerHTML={{
__html: sanitizeHtml(statement?.title || label),
}}
/>
<Description
name={name}
description={sanitizeHtml(statement?.description || description)}
helpCenter={helpCenter}
/>
</>
) : (
<Description
name={name}
description={descriptionSanitized}
helpCenter={helpCenter}
{titleSanitized && (
<p
className={`text-sm RemoteFlows__ForcedValue__Title__${name}`}
dangerouslySetInnerHTML={{
__html: titleSanitized,
}}
/>
)}
<Description
name={name}
description={descriptionSanitized}
helpCenter={helpCenter}
/>
</div>
);
}
4 changes: 2 additions & 2 deletions src/components/form/fields/tests/ForcedValueField.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ describe('ForcedValueField Component', () => {
});

describe('when statement is not provided', () => {
it('renders only the description', () => {
it('renders only the label and description', () => {
renderWithFormContext(defaultProps);

expect(
screen.getByText('This is a test description'),
).toBeInTheDocument();
expect(screen.queryByText('Test Label')).not.toBeInTheDocument();
expect(screen.getByText('Test Label')).toBeInTheDocument();
});
});

Expand Down
10 changes: 7 additions & 3 deletions src/components/form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,13 @@ export function getFieldsWithFlatFieldsets({
return accumulatedFieldsSorted;
}, fields);

const filteredFields = sortedFields.filter(
(field) => !flatFieldsetsFieldNames.has(field.name!),
);
const filteredFields = sortedFields.filter((field) => {
// Always keep the fieldset wrapper
if (field.type === 'fieldset-flat') {
return true;
}
return !flatFieldsetsFieldNames.has(field.name!);
});

return filteredFields;
}
Expand Down
Loading