Skip to content

fix/03-4454: Clicking on the Order Basket should not do anything when the order basket is open #2468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jwnasambu
Copy link
Contributor

@jwnasambu jwnasambu commented May 22, 2025

… the order basket is open

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

To ensure that clicking the shopping cart icon does nothing when the "order-basket" workspace is already open, I created a function to:

  1. Check if the workspace is open.

  2. Then, wrap the icon in a clickable element that cancels the click event if the workspace is already active.

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-4454

Other

@jwnasambu jwnasambu changed the title fix/03-4454: Clicking on the Order Basket should not do anything when… fix/03-4454: Clicking on the Order Basket should not do anything when the order basket is open May 22, 2025
@jwnasambu jwnasambu marked this pull request as draft May 22, 2025 20:55
Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is better to make this more general, i.e., by moving this into the launchWorkspace() function in core and just make it do nothing if the requested workspace is the same as the current workspace.

The tricky bit here is that the order basket uses multiple workspaces, and we want the button to do nothing (other than maybe collapse the workspace) for all of them.

Comment on lines 22 to 25
onClick={(e) => {
if (isWorkspaceOpen) {
e.stopPropagation();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this kind of guard here? Isn't it enough to just change the handleClick() stuff?

import { useLaunchWorkspaceRequiringVisit, useOrderBasket } from '@openmrs/esm-patient-common-lib';

const OrderBasketActionButton: React.FC = () => {
const { t } = useTranslation();
const { orders } = useOrderBasket();
const { activeWorkspace } = useWorkspaceContext();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this exists? There is a useWorkspaces(), but that may require additional details. I don't think it tells you what workspace is active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants