Skip to content

Commit

Permalink
Merge pull request #162 from OpenLMIS-Angola/OAM-287
Browse files Browse the repository at this point in the history
OAM-287: fixed scroll on requisition order create page and failing tests
  • Loading branch information
olewandowski1 authored Aug 1, 2024
2 parents 38a25bd + 07884c4 commit 95fab50
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
24 changes: 13 additions & 11 deletions src/react-components/modals/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ const Modal = ({ isOpen, body, alertModal = false, sourceOfFundStyle = '' }) =>

}, [isOpen]);

// When isOpen is false component should return nothing
// Added because if modal is unmounted document.body.style.overflow is not changing to 'auto'
// and scroll doesn't work
if (!isOpen) {
return null
}
return (
<div className={`${showHideClassName} ${alertModalClassName}`}>
<section className={`modal-main ${sourceOfFundStyle ? 'source-of-fund-modal' : ''}`}>
{body}
</section>
</div>
<>
{
isOpen &&
(
<div className={`${showHideClassName} ${alertModalClassName}`}>
<section className={`modal-main ${sourceOfFundStyle ? 'source-of-fund-modal' : ''}`}>
{body}
</section>
</div>
)
}
</>

);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ describe('referencedata-facilities-cache run', function() {
this.postLogoutAction = this.getLastCall(loginServiceSpy.registerPostLogoutAction).args[0];

spyOn(this.facilityService, 'cacheAllMinimal');
spyOn(this.facilityService, 'getFacilitiesWithoutWards');
spyOn(this.facilityService, 'clearMinimalFacilitiesCache');
spyOn(this.facilityService, 'clearFacilitiesWithoutWardsCache');
});

describe('run block', function() {
Expand Down
5 changes: 4 additions & 1 deletion src/requisition-order-create/order-create-table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ const OrderCreateTable = ({ isReadOnly }) => {
isOpen={isSummaryModalOpen}
orders={orders}
onSaveClick={sendOrders}
onModalClose={() => setIsSummaryModalOpen(false)}
onModalClose={() => {
document.body.style.overflow = 'auto';
setIsSummaryModalOpen(false)}
}
/>
}
<div className="page-header-responsive">
Expand Down
4 changes: 2 additions & 2 deletions src/requisition-view/requisition-view.controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('RequisitionViewController', function() {

expect(this.vm.getPrintUrl())
// Angola - changed requisition print URL
.toEqual(this.requisitionUrlFactory('/api/reports/requisitions/requisition-id-1/print'));
.toEqual(this.requisitionUrlFactory('/api/requisitions/requisition-id-1/print'));
// ends here
});

Expand Down Expand Up @@ -653,7 +653,7 @@ describe('RequisitionViewController', function() {
this.$rootScope.$apply();

expect(this.accessTokenFactory.addAccessToken)
.toHaveBeenCalledWith(this.requisitionUrlFactory('api/reports/requisitions/requisition-id-1/print'));
.toHaveBeenCalledWith(this.requisitionUrlFactory('api/requisitions/requisition-id-1/print'));
});

it('should not open report when sync failed', function() {
Expand Down

0 comments on commit 95fab50

Please sign in to comment.