OBPIH-7183 Fix Receiving quantities disappear after edit - if hand typed#5638
OBPIH-7183 Fix Receiving quantities disappear after edit - if hand typed#5638alannadolny merged 1 commit intorelease/0.9.6-hotfix1from
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug (OBPIH-7183) where receiving quantities would disappear after editing if they were hand-typed. The root cause was that the saveEditLine method was reading from stale component state (this.state.values) instead of using the current form values (formValues) passed from React Final Form.
Key changes:
- Updated
saveEditLineto useformValuesparameter consistently throughout the method - Ensures hand-typed quantities are preserved during the save operation
- Maintains data consistency between the form state and component state
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| */ | ||
| saveEditLine(editLines, parentIndex, formValues, rowIndex) { | ||
| const { containers } = this.state.values; | ||
| const { containers } = formValues; |
There was a problem hiding this comment.
Previously we used this.state.values to get container data, which was stale when user hand typed values (quantityReceiving). We should get data from formValues instead, which is already passed to this function and contains the current form state.
The saveEditLine function is only called from EditLineModal.jsx:
save(values) {
this.state.attr.saveEditLine(
values.lines,
this.state.attr.parentIndex,
this.props.values,
this.props.rowIndex,
);
}
Alternative we can update this.state.values on onChange or onBlur, but I think the best option is just use fresh data from formValues
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/0.9.6-hotfix1 #5638 +/- ##
=======================================================
Coverage ? 8.52%
Complexity ? 1127
=======================================================
Files ? 712
Lines ? 45648
Branches ? 10911
=======================================================
Hits ? 3890
Misses ? 41179
Partials ? 579 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
✨ Description of Change
Link to GitHub issue or Jira ticket:
https://pihemr.atlassian.net/browse/OBPIH-7183
Description:
📷 Screenshots & Recordings (optional)