Skip to content

Commit ade0baa

Browse files
committed
BN-64 | Fix. Remove Close ActionArea Fn From PatientHeaderButton
1 parent 4a6cdaa commit ade0baa

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/components/clinical/patientHeader/PatientHeader.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ const PatientHeader: React.FC<PatientHeaderProps> = ({
2222
}) => {
2323
const { t } = useTranslation();
2424

25+
const handleOnButtonClick = () => {
26+
if (!isActionAreaVisible) setIsActionAreaVisible(true);
27+
};
28+
2529
return (
2630
<Tile aria-label={t('PATIENT_HEADER_LABEL')} className={styles.header}>
2731
<Grid>
@@ -40,11 +44,7 @@ const PatientHeader: React.FC<PatientHeaderProps> = ({
4044
xl={isActionAreaVisible ? 6 : 3}
4145
className={styles.controls}
4246
>
43-
<Button
44-
size="lg"
45-
onClick={() => setIsActionAreaVisible(!isActionAreaVisible)}
46-
renderIcon={Add}
47-
>
47+
<Button size="lg" onClick={handleOnButtonClick} renderIcon={Add}>
4848
{t('PATIENT_HEADER_SHOW_ACTION_AREA')}
4949
</Button>
5050
</Column>

src/components/clinical/patientHeader/__tests__/PatientHeader.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@ describe('PatientHeader Component', () => {
9898
expect(mockSetIsActionAreaVisible).toHaveBeenCalledWith(true);
9999
});
100100

101-
test('calls setIsActionAreaVisible with toggled value when button is clicked (starting with true)', () => {
101+
test('setIsActionAreaVisible is not called when action area is already visible', () => {
102102
renderComponent({ isActionAreaVisible: true });
103103
const button = screen.getByRole('button');
104104

105105
fireEvent.click(button);
106106

107-
expect(mockSetIsActionAreaVisible).toHaveBeenCalledTimes(1);
108-
expect(mockSetIsActionAreaVisible).toHaveBeenCalledWith(false);
107+
expect(mockSetIsActionAreaVisible).toHaveBeenCalledTimes(0);
109108
});
110109
});
111110

0 commit comments

Comments
 (0)