diff --git a/src/prescriptions/prescription-tab-lists.component.tsx b/src/prescriptions/prescription-tab-lists.component.tsx index da8cc52..49f5e81 100755 --- a/src/prescriptions/prescription-tab-lists.component.tsx +++ b/src/prescriptions/prescription-tab-lists.component.tsx @@ -8,22 +8,15 @@ import { useConfig } from "@openmrs/esm-framework"; import { PharmacyConfig } from "../config-schema"; import { SimpleLocation } from "../types"; -enum TabTypes { - STARRED, - SYSTEM, - USER, - ALL, -} - const PrescriptionTabLists: React.FC = () => { const { t } = useTranslation(); const config = useConfig() as PharmacyConfig; const { filterLocations, isLoading: isFilterLocationsLoading } = useLocationForFiltering(config); - const [selectedTab, setSelectedTab] = useState(TabTypes.STARRED); const [searchTermUserInput, setSearchTermUserInput] = useState(""); // we have a separate "searchTermUserInput" and "searchTerm" in order to debounce const [searchTerm, setSearchTerm] = useState(""); const [location, setLocation] = useState(""); + const [selectedTab, setSelectedTab] = useState(0); const tabs = [ { @@ -47,14 +40,19 @@ const PrescriptionTabLists: React.FC = () => { return () => clearTimeout(debounceFn); }, [searchTermUserInput]); + // we use this to only render the tab panel that is currently selected, see O3-2777 + const handleTabChange = (event) => { + setSelectedTab(event.selectedIndex); + }; + return (
{ {tabs.map((tab, index) => { - return ( + return index === selectedTab ? ( + ) : ( + <> ); })}