Skip to content

Commit

Permalink
removes content while loading, fixes focus state
Browse files Browse the repository at this point in the history
  • Loading branch information
agravell047 committed Nov 27, 2024
1 parent 2217ab5 commit ec50daf
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions src/applications/mhv-medications/containers/Prescriptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,16 @@ const Prescriptions = () => {

useEffect(
() => {
if (!filteredList?.length) {
if (
!isLoading &&
filteredList?.length === 0 &&
filterCount &&
Object.values(filterCount).some(value => value !== 0)
) {
focusElement(document.getElementById('no-matches-msg'));
}
},
[filteredList],
[filteredList, isLoading, filterCount],
);

useEffect(
Expand Down Expand Up @@ -733,10 +738,12 @@ const Prescriptions = () => {
<BeforeYouDownloadDropdown page={pageType.LIST} />
</>
)}
<MedicationsListSort
value={selectedSortOption}
sortRxList={sortRxList}
/>
{(!showFilterContent || !isLoading) && (
<MedicationsListSort
value={selectedSortOption}
sortRxList={sortRxList}
/>
)}
<div className="rx-page-total-info vads-u-border-color--gray-lighter" />
{isLoading ? (
<div className="vads-u-height--viewport vads-u-padding-top--3">
Expand All @@ -759,24 +766,25 @@ const Prescriptions = () => {
updateLoadingStatus={updateLoadingStatus}
/>
)}
{showFilterContent && (
<>
<PrintDownload
onDownload={handleFullListDownload}
isSuccess={
pdfTxtGenerateStatus.status ===
PDF_TXT_GENERATE_STATUS.Success
}
isLoading={
!allergiesError &&
pdfTxtGenerateStatus.status ===
PDF_TXT_GENERATE_STATUS.InProgress
}
list
/>
<BeforeYouDownloadDropdown page={pageType.LIST} />
</>
)}
{showFilterContent &&
!isLoading && (
<>
<PrintDownload
onDownload={handleFullListDownload}
isSuccess={
pdfTxtGenerateStatus.status ===
PDF_TXT_GENERATE_STATUS.Success
}
isLoading={
!allergiesError &&
pdfTxtGenerateStatus.status ===
PDF_TXT_GENERATE_STATUS.InProgress
}
list
/>
<BeforeYouDownloadDropdown page={pageType.LIST} />
</>
)}
</>
) : (
<>
Expand All @@ -793,7 +801,8 @@ const Prescriptions = () => {
)}
{showFilterContent && (
<>
{filteredList?.length === 0 &&
{!isLoading &&
filteredList?.length === 0 &&
filterCount &&
Object.values(filterCount).some(
value => value !== 0,
Expand Down

0 comments on commit ec50daf

Please sign in to comment.