Skip to content
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

(fix) O3-4299: Missing Label in Dropdown Menu of Service Queues #1425

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

Conversation

harshthakkr
Copy link
Contributor

@harshthakkr harshthakkr commented Jan 3, 2025

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

This PR addresses an issue where the second clinic metric in Service Queues displayed an empty string instead of the label 'All' when defaulting to show data for all. The label has been updated to display 'All' by default, ensuring clarity and consistency in the UI.

Screenshots

Before:
Screenshot 2025-01-03 at 6 37 10 PM

After:
Screenshot 2025-01-03 at 6 55 23 PM

Related Issue

O3-4299

@Muppasanipraneeth
Copy link
Contributor

@harshthakkr update test also

@harshthakkr
Copy link
Contributor Author

@Muppasanipraneeth I am working on it.

@harshthakkr
Copy link
Contributor Author

One test is failing due to the new year (2025). @chibongho has created a PR to update the test. Their PR needs to be merged first to ensure all e2e tests pass.

@@ -67,7 +67,7 @@ function ClinicMetrics() {
itemToString={(item) =>
item ? `${item.display} ${item.location?.display ? `- ${item.location.display}` : ''}` : ''
}
label=""
label={t('all', 'All')}
onChange={handleServiceChange}
Copy link
Member

@denniskigen denniskigen Jan 6, 2025

Choose a reason for hiding this comment

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

Hardcoding All as the label for the default item in the dropdown is not the right approach. If the goal is to show a default value for the dropdown, we should use the initialSelectedItem prop. This allows us to show the default value in the dropdown and also allows us to use the itemToString function to format the item as a string.

To achieve, this we can modify the logic as follows:

const defaultServiceItem = {
  display: `${t('all', 'All')}`,
  uuid: '',
};

const serviceItems = [defaultServiceItem, ...(services ?? [])];

And then further down the line, we can use these values to set the initialSelectedItem prop and the items prop:

<Dropdown
  initialSelectedItem={defaultServiceItem}
  items={serviceItems}
  label=""
  // ... other props
/>

Copy link
Member

Choose a reason for hiding this comment

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

A nice, optional extra touch would be annotating serviceItems with the proper types.

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.

3 participants