Skip to content

Commit

Permalink
Remove extra label and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondyr committed Jan 22, 2025
1 parent e844f92 commit 594a238
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import React, { type ChangeEvent } from 'react';
import classes from './EmptyTextField.module.css';
import type { Summary2OverrideConfig } from 'app-shared/types/ComponentSpecificConfig';
import {
StudioAlert,
StudioLabelAsParagraph,
StudioProperty,
StudioTextfield,
} from '@studio/components';
import { StudioAlert, StudioProperty, StudioTextfield } from '@studio/components';
import { useTranslation } from 'react-i18next';

type EmptyTextFieldProps = {
Expand Down Expand Up @@ -38,19 +33,15 @@ export const EmptyTextField = ({ onChange, override }: EmptyTextFieldProps) => {
}

return (
<>
<StudioLabelAsParagraph>
{t('ux_editor.component_properties.summary.override.empty_field_text')}
</StudioLabelAsParagraph>
<StudioTextfield
autoFocus={true}
onBlur={() => setOpen(false)}
onKeyDown={({ key }) => key === 'Enter' && setOpen(false)}
value={override.emptyFieldText}
onChange={(event: ChangeEvent<HTMLInputElement>) =>
onChange({ ...override, emptyFieldText: event.target.value })
}
/>
</>
<StudioTextfield
label={t('ux_editor.component_properties.summary.override.empty_field_text')}
autoFocus={true}
onBlur={() => setOpen(false)}

Check warning on line 39 in frontend/packages/ux-editor/src/components/config/componentSpecificContent/Summary2/Override/OverrideFields/EmptyTextField.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/packages/ux-editor/src/components/config/componentSpecificContent/Summary2/Override/OverrideFields/EmptyTextField.tsx#L39

Added line #L39 was not covered by tests
onKeyDown={({ key }) => key === 'Enter' && setOpen(false)}
value={override.emptyFieldText}
onChange={(event: ChangeEvent<HTMLInputElement>) =>
onChange({ ...override, emptyFieldText: event.target.value })
}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ describe('Summary2Override', () => {
await userEvent.click(overrideCollapsedButton(1));
const emptyFieldText = 'asdf;ljr%';
const textFieldButton = screen.getByRole('button', {
name: textMock('ux_editor.component_properties.summary.override.empty_field_text'),
name: /ux_editor.component_properties.summary.override.empty_field_text/i,
});
await user.click(textFieldButton);
await user.type(
screen.getByLabelText(
textMock('ux_editor.component_properties.summary.override.empty_field_text'),
),
screen.getByRole('textbox', {
name: /ux_editor.component_properties.summary.override.empty_field_text/i,
}),
emptyFieldText,
);
await waitFor(() =>
Expand Down

0 comments on commit 594a238

Please sign in to comment.