diff --git a/packages/esm-patient-search-app/src/patient-search-page/patient-banner/banner/patient-banner.component.tsx b/packages/esm-patient-search-app/src/patient-search-page/patient-banner/banner/patient-banner.component.tsx index b9eb75f9b..b70d54807 100644 --- a/packages/esm-patient-search-app/src/patient-search-page/patient-banner/banner/patient-banner.component.tsx +++ b/packages/esm-patient-search-app/src/patient-search-page/patient-banner/banner/patient-banner.component.tsx @@ -1,4 +1,4 @@ -import React, { MouseEvent } from 'react'; +import React, { MouseEvent, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { Button, ButtonSkeleton, SkeletonIcon, SkeletonText } from '@carbon/react'; import { ChevronDown, ChevronUp, OverflowMenuVertical } from '@carbon/react/icons'; @@ -11,6 +11,7 @@ import { interpolateString, useConfig, ConfigurableLink, + useConnectedExtensions, } from '@openmrs/esm-framework'; import { SearchedPatient } from '../../../types'; import ContactDetails from '../contact-details/contact-details.component'; @@ -39,6 +40,7 @@ const PatientBanner: React.FC = ({ const { currentVisit } = useVisit(patientUuid); const [showDropdown, setShowDropdown] = React.useState(false); const config = useConfig(); + const patientSearchActions = useConnectedExtensions('patient-search-actions-slot'); const patientActionsSlotState = React.useMemo( () => ({ patientUuid, selectPatientAction, onTransition, launchPatientChart: true }), @@ -65,6 +67,11 @@ const PatientBanner: React.FC = ({ setShowDropdown((value) => !value); }, []); + const showActionsMenu = useMemo( + () => !hideActionsOverflow && patientSearchActions.length > 0, + [patientSearchActions.length, hideActionsOverflow], + ); + const getGender = (gender) => { switch (gender) { case 'M': @@ -121,7 +128,7 @@ const PatientBanner: React.FC = ({
- {!hideActionsOverflow && ( + {showActionsMenu && (