Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
IOU - digit appears cutoff for a moment when entering a digit before decimal point #18579
base: main
Are you sure you want to change the base?
IOU - digit appears cutoff for a moment when entering a digit before decimal point #18579
Changes from 3 commits
9fad803
3c4a37a
ae5eaad
e4c70a3
f40d168
710d9da
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I have been playing around with this PR to try to avoid this bug, and I'm pretty sure that this is the change causing it.
When the input is full and you type a new digit,
value
comes with that new digit, and is longer than the permitted value, but we used to set it in the state anyway. Then,componentDidUpdate
is called and the value coming from the props is the truncated version. Since the truncated value is different than thestate.value
, we set the truncated value in the state.With this change, we don't set the longer than permitted value in the state immediately as we used to, and we end up rendering the input with an old
state.value
because we are waiting for the width to be calculated.I don't understand fully the problem, but I think it is related to this.
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.
@aldo-expensify yes you are right that we set state immediately without waiting width calculation - this is the issue we currently have - and to avoid this we should not use state variable for input until width will be calculated
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.
@aldo-expensify And also to be clear about render logic:
Why bug with jumping cursor appears - we do not use state value to save longer value - we pass it directly to
src/pages/iou/steps/MoneyRequestAmountPage.js
- inside that page - there is a set state - which cut un needed symbol - put in state and fire re-render.In BaseTextInput - we receive that value - and compare with value which we have in state
Both are equal - and we do not make any changes in setState - because we get here
But we still in re-render process - because MoneyRequestAmountPage page force re-render by doing setState.
TextInput - get this re-render and check - that value is still the same - but it was detecting keyboard press - and setSelectionChange will be fired here:
And e.nativeEvent.selection will be last position of the element in input
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.
I was thinking that this could be a could point to set the
state.value = defaultHiddenInputValue
whenthis.props.shouldWaitWidthCalculation = true
, so you don't have to wait for another cycle to updatestate.value
.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.
@aldo-expensify you mean to set value inside second parameter of this.setState?
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.
No, In the same first parameter. I think that may be the earliest time we can set the
state.value
without running into the width problem cutting off the number.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.
As @parasharrajat posted, I agree it would be good to investigate this further before just disabling it for desktop. If we don't understand the cause, we may be creating a bug.