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-3958: Allow user to select all answer options #389

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Muta-Jonathan
Copy link
Member

@Muta-Jonathan Muta-Jonathan commented Feb 4, 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

  1. Due to this feature in the new carbon versions ... I had to upgrade our carbon version to "@carbon/react": "^1.75.0", which is the latest as per this PR
  2. Our old implementation was using the current state of formField.questionOptions?.answers which wen updated from the
setFormField((prevField) => {
        const currentAnswers = prevField.questionOptions?.answers || [];
        if (JSON.stringify(currentAnswers) === JSON.stringify(mappedAnswers)) {
          return prevField;
        }
        return {
          ...prevField,
          questionOptions: {
            ...prevField.questionOptions,
            answers: mappedAnswers,
          },
        };
      });

would trigger changes to the formfields hence making

<MultiSelect
          className={styles.multiSelect}
          direction="top"
          id="selectAnswers"
          items={answerItems}
          itemToString={convertAnswerItemsToString}
          onChange={handleSelectAnswers}
          size="md"
          selectedItems={selectedAnswers}
          titleText={t('selectAnswersToDisplay', 'Select answers to display')}
        /> 

to show only selected items as options
Now with this new implementation have introduced the useRef to store the initial state of
const initialAnswers = useRef(formField.questionOptions?.answers ?? []); so as to show all selected and unselected question answers

Screen recording

Screen.Recording.2025-02-05.at.2.02.21.AM.mov

Related Issue

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

@Muta-Jonathan Muta-Jonathan requested review from NethmiRodrigo, pirupius and ibacher and removed request for NethmiRodrigo and pirupius February 4, 2025 23:17
@NethmiRodrigo NethmiRodrigo changed the title (fix) O3-3958: Select all concept answers in Edit question Modal via the Interactive schema builder (fix) O3-3958: Allow user to select all answer options Feb 5, 2025
Copy link
Collaborator

@NethmiRodrigo NethmiRodrigo left a comment

Choose a reason for hiding this comment

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

Thanks @Muta-Jonathan! A couple of things, the select all option isn't showing up when I run this locally, so please double check this fix and include a screenshot of how it works. Additionally, you'd have to override the import map and test within the app shell and try locally linking the form engine and running because the carbon update is still pending in the form engine and might cause issues.

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