-
Notifications
You must be signed in to change notification settings - Fork 13
fix(Input): Does not update value as expected #1782
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
base: dev
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: c54923c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
What changes were made after reverting it? Do we know the root cause of the previous issue? |
As @moathabuhamad-cengage explained to me, maybe these changes added some breaking change in other Cengage repos that's way it was reverted, I am right, Moa? |
Right. We don't want to have breaking changes, so we need to investigate what about this pull request is causing our adopters to break before we merge it back. |
4f75040
to
c5eb083
Compare
@olehnoskov-cengage I added a storybook example and a few tests to match the errors we saw in the adopters repo, now you can fix the ticket with these included. those tests pass on current dev but fail on this branch |
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.
Just curious-- I am seeing new tests, but no changes to the input component. Do we know the root cause of what caused our adopter's tests to fail with the code changes we introduced?
Yes, @moathabuhamad-cengage suggested adding new tests to monitor breaking changes on the adopter's side. |
Closes: #1721
What I did
Input
on the customer side to track break changes.Screenshots
Screencast.from.11.04.25.10.50.08.webm
Storybook:


Checklist
How to test
Minutes
field (RM input)1
hour and in Minutes should be6
On the customer side need add this line to fix this issue:
isHours ? setHours(currentUnitValue) : setMinutes(currentUnitValue);
You can take a look at the implementation
onChangeTimedDuration
functionWhy should the customer update the current Implementation?
The main issue lies in this line:
const currentUnitValue = numericValue && numericValue >= 0 ? numericValue : 0;
Let’s say
numericValue === 66
. Based on totalDurationMilliseconds, the parsed minutes become 6, so we call setMinutes(6). However, if the current state minutes is already 6, React sees no change and skips the re-render.As a result:
Why This Works Differently in Native Inputs vs. React Magma Input
Native inputs update their displayed value immediately, independent of React state — they're "uncontrolled" in that sense. In contrast,
InputBase
andInput
components in React Magma are state-driven and semi-controlled. Their displayed value is tied to React state and props.If the parent component fails to re-set the value explicitly, or if React optimizes away a no-op update, the visual value may fall out of sync with the actual state — especially when parsing alters the value (like converting 66 to 6).