Skip to content

Commit

Permalink
layoutSet target as default after updated feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lassopicasso committed Dec 4, 2024
1 parent 378bd6b commit 4555496
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Summary2ComponentTargetSelector', () => {

expect(addNewOverrideButton()).toBeInTheDocument();

expect(pageTargetSelect()).toBeInTheDocument();
expect(disabledLayoutSetTargetSelect()).toBeInTheDocument();
});

it('should select the task id from the current layout when the task id of the target is not defined', async () => {
Expand Down Expand Up @@ -74,10 +74,11 @@ describe('Summary2ComponentTargetSelector', () => {
);
});

it('should defaults to page target and to current layout', async () => {
it('should defaults to page target and disabled target select', async () => {
render();
expect(targetTypeSelect()).toHaveValue('page');
expect(pageTargetSelect()).toHaveValue(layout1NameMock);
expect(targetTypeSelect()).toHaveValue('layoutSet');
expect(disabledLayoutSetTargetSelect()).toBeDisabled();
expect(disabledLayoutSetTargetSelect()).toHaveValue(layoutSet1NameMock);
});

it('should allow selecting layoutSet target', async () => {
Expand Down Expand Up @@ -181,6 +182,11 @@ const pageTargetSelect = () =>
name: textMock('ux_editor.component_properties.target_unit_page'),
});

const disabledLayoutSetTargetSelect = () =>
screen.getByRole('textbox', {
name: textMock('ux_editor.component_properties.target_unit_layout_set'),
});

const addNewOverrideButton = () =>
screen.getByRole('button', {
name: textMock('ux_editor.component_properties.summary.add_override'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ export const Summary2Target = ({ target, onChange }: Summary2TargetProps) => {
</StudioNativeSelect>
{target.type === 'page' && (
<Summmary2ComponentReferenceSelector
key={Boolean(target.id) ? target.id : selectedFormLayoutName} // TODO: Remove the key when https://github.com/digdir/designsystemet/issues/2264 is fixed
key={target.id} // TODO: Remove the key when https://github.com/digdir/designsystemet/issues/2264 is fixed
label={t('ux_editor.component_properties.target_unit_page')}
value={Boolean(target.id) ? target.id : selectedFormLayoutName}
value={target.id}
options={pageOptions}
onValueChange={handleTargetIdChange}
/>
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/ux-editor/src/data/formItemConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export const formItemConfigs: FormItemConfigs = {
itemType: LayoutItemType.Component,
defaultProperties: {
target: {
type: 'page',
type: 'layoutSet',
id: '',
taskId: '',
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/ux-editor/src/testing/componentMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const repeatingGroupContainer: FormContainer<ComponentType.RepeatingGroup> = {
const summary2Component: FormComponent<ComponentType.Summary2> = {
...commonProps(ComponentType.Summary2),
target: {
type: 'page',
type: 'layoutSet',
},
};

Expand Down

0 comments on commit 4555496

Please sign in to comment.