Skip to content

Commit

Permalink
(fix) Fix subtle bug in resolve promise in print button
Browse files Browse the repository at this point in the history
Fixes a subtle bug in the OrderDetailsTable print button where the promise was resolved with a function call instead of the resolve function itself. Also fixes the fill color of the print and add buttons.
  • Loading branch information
denniskigen committed Nov 13, 2024
1 parent 7b6eb1a commit 219e370
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,19 @@
@include type.type-style('helper-text-02');
}

.button {
svg {
fill: currentColor !important;
}
}

.printButton {
margin-left: 1.25rem;
@extend .button;
}

.addButton {
@extend .button;
}

@media print {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ const OrderDetailsTable: React.FC<OrderDetailsProps> = ({ patientUuid, showAddBu
const handlePrint = useReactToPrint({
content: () => contentToPrintRef.current,
documentTitle: `OpenMRS - ${patientDetails.name} - ${title}`,
onBeforeGetContent: (): Promise<void> =>
onBeforeGetContent: () =>
new Promise((resolve) => {
if (patient && title) {
onBeforeGetContentResolve.current = resolve();
onBeforeGetContentResolve.current = resolve;
setIsPrinting(true);
}
}),
Expand Down Expand Up @@ -362,17 +362,18 @@ const OrderDetailsTable: React.FC<OrderDetailsProps> = ({ patientUuid, showAddBu
<div className={styles.buttons}>
{showPrintButton && (
<Button
kind="ghost"
renderIcon={PrinterIcon}
iconDescription={t('printOrder', 'Print order')}
className={styles.printButton}
iconDescription={t('printOrder', 'Print order')}
kind="ghost"
onClick={handlePrint}
renderIcon={PrinterIcon}
>
{t('print', 'Print')}
</Button>
)}
{showAddButton && (
<Button
className={styles.addButton}
kind="ghost"
renderIcon={AddIcon}
iconDescription={t('launchOrderBasket', 'Launch order basket')}
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-orders-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const configSchema = {
},
showPrintButton: {
_type: Type.Boolean,
_default: false,
_description:
'Determines whether or not to display a Print button in the Orders details table. If set to true, a Print button gets shown in both the orders table headers. When clicked, this button enables the user to print out the contents of the table',
_default: false,
},
};

Expand Down

0 comments on commit 219e370

Please sign in to comment.