-
Notifications
You must be signed in to change notification settings - Fork 473
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
Fixes UI Bug Issue in Symptom Editor #9270
base: develop
Are you sure you want to change the base?
Fixes UI Bug Issue in Symptom Editor #9270
Conversation
WalkthroughThe pull request introduces several modifications across multiple components, primarily focusing on enhancing the user interface and accessibility. The Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (4)
src/components/Form/FormFields/DateFormField.tsx (2)
40-43
: LGTM! The styling changes address the UI alignment issues.The addition of margin and text ellipsis classes aligns with the PR objectives to fix the UI bugs in the date input field.
Consider these improvements:
- Use a CSS variable for the margin to make it configurable:
-"mr-9 text-ellipsis" +"mr-[var(--date-input-margin,2.25rem)] text-ellipsis"
- Add a comment explaining the purpose of these specific classes for future maintainability:
className={classNames( field.error && "border-red-500", - "mr-9 text-ellipsis", + // Right margin for dropdown icon alignment, ellipsis for overflow handling + "mr-[var(--date-input-margin,2.25rem)] text-ellipsis", )}
Line range hint
39-58
: Consider forwarding the title prop for accessibility.The AI summary mentions that
DateInputV2
now supports atitle
property for accessibility, but it's not being passed through fromDateFormField
. Consider adding this capability to improve accessibility.Add the title prop to the Props type and forward it:
type Props = FormFieldBaseProps<Date> & { containerClassName?: string; placeholder?: string; max?: Date; min?: Date; disableFuture?: boolean; disablePast?: boolean; allowTime?: boolean; popOverClassName?: string; + title?: string; // For accessibility tooltip }; // In the component render <DateInputV2 // ... other props + title={props.title} />src/components/Symptoms/SymptomsBuilder.tsx (2)
201-208
: Remove redundant block statements to simplify the codeThe block statements around the conditional expression in lines 201-208 are unnecessary and can be safely removed to simplify the code, as indicated by static analysis tools.
Apply this diff to remove the redundant block:
- { "id" in item ? setItem({ onset_date: dateQueryString(value), id: item.id, }) : setItem({ ...item, onset_date: dateQueryString(value) }); - } + "id" in item + ? setItem({ + onset_date: dateQueryString(value), + id: item.id, + }) + : setItem({ ...item, onset_date: dateQueryString(value) });🧰 Tools
🪛 Biome (1.9.4)
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
225-235
: Remove redundant block statements to simplify the codeSimilarly, the block statements in lines 225-235 are unnecessary and can be removed to clean up the code.
Apply this diff:
- { "id" in item ? setItem({ cure_date: dateQueryString(value), id: item.id, }) : setItem({ ...(item as EncounterSymptom), cure_date: dateQueryString(value), }); - } + "id" in item + ? setItem({ + cure_date: dateQueryString(value), + id: item.id, + }) + : setItem({ + ...(item as EncounterSymptom), + cure_date: dateQueryString(value), + });🧰 Tools
🪛 Biome (1.9.4)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (6)
src/components/Common/DateInputV2.tsx
(1 hunks)src/components/Form/FormFields/AutocompleteMultiselect.tsx
(1 hunks)src/components/Form/FormFields/DateFormField.tsx
(1 hunks)src/components/Form/ModelCrudEditor.tsx
(2 hunks)src/components/Symptoms/SymptomsBuilder.tsx
(4 hunks)src/components/Symptoms/types.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/components/Common/DateInputV2.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Symptoms/SymptomsBuilder.tsx
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🔇 Additional comments (2)
src/components/Form/ModelCrudEditor.tsx (1)
Line range hint 103-124
: LGTM
The adjustments to the layout enhance the component's responsiveness without affecting functionality.
src/components/Form/FormFields/AutocompleteMultiselect.tsx (1)
174-185
: Improve alignment and positioning of the dropdown icon
The modifications to the ComboboxButton
and associated classes enhance the visual alignment of the dropdown icon, providing a better user experience.
…issues/8998/symptoms-editor-fix
…JavidSumra/care_fe into issues/8998/symptoms-editor-fix
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
src/components/Symptoms/SymptomsBuilder.tsx (3)
101-138
: Enhance error handling in createSymptom functionThe function should handle API errors more gracefully and provide more specific success messages.
Consider applying these improvements:
const createSymptom = async (body: EncounterSymptomRequest) => { if (Array.isArray(body.symptom)) { const { symptom, onset_date, other_symptom } = body; const objects = symptom.map((symptom: EncounterSymptom["symptom"]) => ({ symptom, onset_date: dateQueryString(onset_date), other_symptom: symptom === OTHER_SYMPTOM_CHOICE.id ? other_symptom : undefined, })); if (consultationId) { try { const responses = await Promise.all( objects.map((body) => request(SymptomsApi.add, { body, pathParams: { consultationId: consultationId! }, }), ), ); if (responses.every(({ res }) => !!res?.ok)) { - Success({ msg: "Symptoms records updated successfully" }); + Success({ msg: `Successfully added ${objects.length} symptom(s)` }); } else { + throw new Error("Failed to add some symptoms"); } } catch (error) { + console.error("Failed to create symptoms:", error); + throw error; } } } else { try { const { res } = await request(SymptomsApi.add, { pathParams: { consultationId }, body, }); if (res?.ok) { - Success({ msg: "Symptom added successfully" }); + Success({ msg: `Successfully added ${SYMPTOM_CHOICES.find(s => s.id === body.symptom)?.text || 'symptom'}` }); } else { + throw new Error("Failed to add symptom"); } } catch (error) { + console.error("Failed to create symptom:", error); + throw error; } } refetch(); };
183-185
: Review the debounce delay durationThe current debounce delay of 5000ms (5 seconds) seems excessive and might affect user experience.
Consider reducing the delay:
const debouncedSetItem = debounce((value: string) => { setItem({ other_symptom: value, symptom: item.symptom }); -}, 5000); +}, 1000);
199-209
: Remove redundant block statementThe block statement is unnecessary and can be simplified.
Apply this change:
if (!dayjs(onsetDate).isSame(dayjs(value), "second")) { setOnsetDate(value); - { - "id" in item - ? setItem({ - onset_date: dateQueryString(value), - id: item.id, - }) - : setItem({ ...item, onset_date: dateQueryString(value) }); - } + "id" in item + ? setItem({ + onset_date: dateQueryString(value), + id: item.id, + }) + : setItem({ ...item, onset_date: dateQueryString(value) }); }🧰 Tools
🪛 Biome (1.9.4)
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/components/Symptoms/SymptomsBuilder.tsx
(4 hunks)src/components/Symptoms/types.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Symptoms/types.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Symptoms/SymptomsBuilder.tsx
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🔇 Additional comments (1)
src/components/Symptoms/SymptomsBuilder.tsx (1)
354-358
:
Fix the allowCreate condition logic
The current condition incorrectly disables the create button even when symptoms are selected.
Apply this fix:
-allowCreate={(item) =>
- !item.onset_date && Array.isArray(item.symptom)
- ? !item.symptom.length
- : !item.symptom
-}
+allowCreate={(item) =>
+ !(Array.isArray(item.symptom) && item.symptom.length > 0)
+}
Hey @shivankacker, it seems that when we update fields like |
I don't think the tests are failing because of that. Go through test screenshots and see if you can find what is causing the failure |
…JavidSumra/care_fe into issues/8998/symptoms-editor-fix
…issues/8998/symptoms-editor-fix
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
src/components/Symptoms/SymptomsBuilder.tsx (3)
1-1
: Consider adding timezone handling for medical recordsWhen dealing with medical records, it's crucial to handle timezones correctly. Consider using dayjs with timezone plugin to ensure consistent date handling across different regions.
+import timezone from "dayjs/plugin/timezone"; +import utc from "dayjs/plugin/utc"; + +dayjs.extend(utc); +dayjs.extend(timezone);
201-208
: Remove redundant block statementsThe code contains unnecessary block statements that can be simplified.
- { "id" in item ? setItem({ onset_date: dateQueryString(value), id: item.id, }) : setItem({ ...item, onset_date: dateQueryString(value) }); - } - { "id" in item ? setItem({ cure_date: dateQueryString(value), id: item.id, }) : setItem({ ...(item as EncounterSymptom), cure_date: dateQueryString(value), }); - }Also applies to: 225-235
🧰 Tools
🪛 Biome (1.9.4)
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
169-181
: Consider using useReducer for complex state managementThe component uses multiple useState hooks for related state variables. Consider using useReducer to simplify state management and ensure consistent updates.
type SymptomState = { selected: EncounterSymptom["symptom"] | EncounterSymptom["symptom"][]; otherSymptom: string; onsetDate?: Date; onCureDate?: Date; }; type SymptomAction = | { type: 'SET_SELECTED'; payload: EncounterSymptom["symptom"] | EncounterSymptom["symptom"][] } | { type: 'SET_OTHER_SYMPTOM'; payload: string } | { type: 'SET_ONSET_DATE'; payload?: Date } | { type: 'SET_CURE_DATE'; payload?: Date }; const symptomReducer = (state: SymptomState, action: SymptomAction): SymptomState => { switch (action.type) { case 'SET_SELECTED': return { ...state, selected: action.payload }; case 'SET_OTHER_SYMPTOM': return { ...state, otherSymptom: action.payload }; case 'SET_ONSET_DATE': return { ...state, onsetDate: action.payload }; case 'SET_CURE_DATE': return { ...state, onCureDate: action.payload }; default: return state; } };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/components/Common/DateInputV2.tsx
(1 hunks)src/components/Symptoms/SymptomsBuilder.tsx
(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Common/DateInputV2.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Symptoms/SymptomsBuilder.tsx
[error] 201-208: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
[error] 225-235: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🔇 Additional comments (1)
src/components/Symptoms/SymptomsBuilder.tsx (1)
354-358
: Correct the condition in allowCreate
prop to enable symptom creation
The current condition in the allowCreate
prop incorrectly disables the create button even when symptoms are selected. It should be updated to properly reflect when creation is allowed.
@JavidSumra Can you please share the current status of the PR? Otherwise, the PR will be closed in the next 48 hours, and you will be unassigned from the issue due to inactivity. |
…JavidSumra/care_fe into issues/8998/symptoms-editor-fix
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
src/components/Common/DateTextInput.tsx (1)
Line range hint
1-200
: Enhance accessibility and documentationThe component has good keyboard navigation but could benefit from improved accessibility and documentation:
- Add ARIA roles and states for better screen reader support
- Document keyboard navigation in the component's JSDoc
- Add error announcements for screen readers
Consider these improvements:
/** * DateTextInput component. * + * Keyboard Navigation: + * - Left/Right arrows: Navigate between fields + * - Backspace: Move to previous field when empty + * - Delete: Move to next field when empty + * * @param {Object} props - Component properties. */Add ARIA attributes to the container:
<div className={classNames(...)} + role="group" + aria-label="Date and time input" + aria-invalid={!!error} >Add live region for error announcements:
- {error && <span className="text-xs text-red-500">{error}</span>} + {error && ( + <span + className="text-xs text-red-500" + role="alert" + aria-live="polite" + > + {error} + </span> + )}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
cypress/support/commands.ts
(1 hunks)src/components/Common/DateTextInput.tsx
(1 hunks)
🔇 Additional comments (1)
cypress/support/commands.ts (1)
194-197
: Verify test coverage with updated selector
The selector change from data-test-id="date-input"
to id="date-input"
aligns with the component changes in DateTextInput.tsx
. However, this change might affect other tests that rely on the old selector.
Let's verify if other tests might be affected:
✅ Verification successful
Selector change is safe to proceed
The search results show that commands.ts
is the only file using either the old (data-test-id="date-input"
) or new (id="date-input"
) selector. This confirms that the selector change is isolated to the clickAndTypeDate
command in commands.ts
and doesn't affect any other test files in the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining usage of the old selector
rg -l 'data-test-id="date-input"' 'cypress/integration/**/*.{js,ts,jsx,tsx}'
Length of output: 159
Script:
#!/bin/bash
# Let's first find the correct test directory structure
fd -t d "cypress"
# Then search for any remaining usage of the old selector in all cypress files
rg -l 'data-test-id="date-input"' 'cypress/**/*.{js,ts,jsx,tsx}'
# Also search for current usage of the new selector for completeness
rg -l 'id="date-input"' 'cypress/**/*.{js,ts,jsx,tsx}'
Length of output: 288
Script:
#!/bin/bash
# Let's try searching in the cypress directory without the glob pattern
cd cypress
rg -l 'data-test-id="date-input"'
rg -l 'id="date-input"'
# Also list all files in cypress directory to understand the structure
find . -type f -name "*.ts" -o -name "*.js" -o -name "*.tsx" -o -name "*.jsx"
Length of output: 3132
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
cypress/e2e/patient_spec/PatientLogUpdate.cy.ts (1)
Line range hint
332-365
: Enhance MEWS Score test coverage and documentationWhile the test covers basic functionality, it could be more comprehensive and maintainable:
- Document why "9" is the expected score based on the input values
- Add test cases for edge cases and boundary values
- Verify intermediate score changes when updating individual vital signs
Consider expanding the test with additional scenarios:
// Add test cases for different MEWS score ranges it("Verifies MEWS Score calculation for different ranges", () => { // Low risk (0-2) patientLogupdate.typeSystolic("120"); patientLogupdate.typePulse("70"); // ... set other vitals for low risk cy.verifyContentPresence("#consultation-buttons", ["1"]); // Medium risk (3-4) patientLogupdate.typeSystolic("90"); patientLogupdate.typePulse("130"); // ... set other vitals for medium risk cy.verifyContentPresence("#consultation-buttons", ["4"]); // High risk (≥5) patientLogupdate.typeSystolic("85"); patientLogupdate.typePulse("140"); // ... set other vitals for high risk cy.verifyContentPresence("#consultation-buttons", ["9"]); });src/components/Symptoms/SymptomsBuilder.tsx (1)
202-209
: Simplify redundant block statementsThe code contains unnecessary block statements that can be simplified.
Apply this diff to simplify the code:
- { - "id" in item - ? setItem({ - onset_date: dateQueryString(value), - id: item.id, - }) - : setItem({ ...item, onset_date: dateQueryString(value) }); - } + "id" in item + ? setItem({ + onset_date: dateQueryString(value), + id: item.id, + }) + : setItem({ ...item, onset_date: dateQueryString(value) });Apply similar simplification to the block at lines 226-236.
Also applies to: 226-236
🧰 Tools
🪛 Biome (1.9.4)
[error] 202-209: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.(lint/complexity/noUselessLoneBlockStatements)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
cypress/e2e/patient_spec/PatientLogUpdate.cy.ts
(1 hunks)src/components/Symptoms/SymptomsBuilder.tsx
(4 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Symptoms/SymptomsBuilder.tsx
[error] 202-209: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
[error] 226-236: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🔇 Additional comments (2)
src/components/Symptoms/SymptomsBuilder.tsx (2)
355-359
:
Fix the condition in allowCreate prop
The current condition in the allowCreate prop incorrectly prevents symptom creation when symptoms are selected.
Apply this diff to fix the condition:
- allowCreate={(item) =>
- !item.onset_date && Array.isArray(item.symptom)
- ? !item.symptom.length
- : !item.symptom
- }
+ allowCreate={(item) =>
+ item.onset_date && Array.isArray(item.symptom) && item.symptom.length > 0
+ }
Likely invalid or redundant comment.
101-138
:
Enhance error handling in createSymptom function
The error handling in the createSymptom function needs improvement to handle API failures gracefully.
Apply this diff to improve error handling:
const createSymptom = async (body: EncounterSymptomRequest) => {
+ try {
if (Array.isArray(body.symptom)) {
const { symptom, onset_date, other_symptom } = body;
const objects = symptom.map((symptom: EncounterSymptom["symptom"]) => ({
symptom,
onset_date: dateQueryString(onset_date),
other_symptom:
symptom === OTHER_SYMPTOM_CHOICE.id ? other_symptom : undefined,
}));
if (consultationId) {
const responses = await Promise.all(
objects.map((body) =>
request(SymptomsApi.add, {
body,
pathParams: { consultationId: consultationId! },
}),
),
);
- if (responses.every(({ res }) => !!res?.ok)) {
+ const failedResponses = responses.filter(({ res }) => !res?.ok);
+ if (failedResponses.length > 0) {
+ throw new Error(`Failed to create ${failedResponses.length} symptoms`);
+ }
Success({ msg: "Symptoms records updated successfully" });
}
} else {
const { res } = await request(SymptomsApi.add, {
pathParams: { consultationId },
body,
});
if (res?.ok) {
Success({ msg: "Symptom added successfully" });
+ } else {
+ throw new Error("Failed to create symptom");
}
}
refetch();
+ } catch (error) {
+ console.error("Error creating symptom:", error);
+ Error({ msg: error instanceof Error ? error.message : "Failed to create symptom" });
+ }
};
Likely invalid or redundant comment.
Hey @nihal467, the |
https://www.loom.com/share/b0d219030c524e4c8ca6a35660191ff4?sid=44912730-a263-4af0-a768-0af799822c5e @JavidSumra when we initially open the log update page, the component is auto closed without interaction |
…issues/8998/symptoms-editor-fix
…JavidSumra/care_fe into issues/8998/symptoms-editor-fix
@nihal467 need your review. |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Bug Fixes