-
Notifications
You must be signed in to change notification settings - Fork 112
(fix) O3-3958: Allow user to select all answer options #389
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
Conversation
There was a problem hiding this 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.
…into add-select-all-concept-answers
…o avoid updating during render
NethmiRodrigo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Muta-Jonathan the screen recording you have provided doesn't load, so please update the PR with one that demonstrates your implementation
| // Storing the initial questionOptions answers | ||
| const initialAnswers = useRef(formField.questionOptions?.answers ?? []); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were these changes from a bad rebase?
|
Hi @Muta-Jonathan just putting it out, in the video you have put as the implementation I see that when select all is selected and you de-select some option the button should be toggle back right? cause I see that it's not toggling back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion would be :
- Add a state variable isSelectAllDisabled or something on that line
- Update handleSelect to accommodate the changes
| (content, element) => | ||
| content.includes('Total items selected') && content.includes('1') && content.includes('To clear selection'), | ||
| ), | ||
| ).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved readability and maintainability, consider using an array with .every() for validating all expected texts. This way, it's easier to scale if more substrings are added in the future, just like below :
const expectedTexts = ['Total items selected', '1', 'To clear selection'];
screen.getByText((content) => expectedTexts.every((text) => content.includes(text)));
|
Closing this PR since it has been inactive and I resumed the work on #519 |
Requirements
Summary
"@carbon/react": "^1.75.0",which is the latest as per this PRformField.questionOptions?.answerswhich wen updated from thewould trigger changes to the formfields hence making
to show only selected items as options
Now with this new implementation have introduced the
useRef to store the initial state ofconst initialAnswers = useRef(formField.questionOptions?.answers ?? []);so as to show all selected and unselected question answersScreen recording
Screen.Recording.2025-02-05.at.2.02.21.AM.mov
Related Issue
https://openmrs.atlassian.net/browse/O3-3958