-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
composer set correct numberOfLines on intitial render #15296
composer set correct numberOfLines on intitial render #15296
Conversation
@marcochavezf @thesahindia One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
src/components/Composer/index.js
Outdated
@@ -356,6 +366,7 @@ class Composer extends React.Component { | |||
selection={this.state.selection} | |||
onChange={this.shouldCallUpdateNumberOfLines} | |||
onSelectionChange={this.onSelectionChange} | |||
onLayout={() => this.updateNumberOfLinesOnLayoutChange()} |
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.
Let's bind updateNumberOfLinesOnLayoutChange
in constructor
onLayout={() => this.updateNumberOfLinesOnLayoutChange()} | |
onLayout={this.updateNumberOfLinesOnLayoutChange} |
Hey @marcochavezf just wanna know if the final result looks fine. The composer shakes a little when repro this issue with some different steps (forgot to confirm earlier) Steps I taken :-
Screen.Recording.2023-02-21.at.1.30.31.AM.movThe video of the final result after following the steps listed in the OP Screen.Recording.2023-02-21.at.1.31.35.AM.mov |
Oh interesting, it looks like a bug, do we know why the composer shakes? Is that still happening after applying the solution? |
Copy pasting @Pujan92's comment here -
The root cause is same as above when we follow the steps I provided. The composer moves a little because we are updating the |
0040b2a
to
8442a94
Compare
@thesahindia with your provided scenario I am seeing the rows issue after I did the latest commit with function bind, in the last(Press ➡️ button) step it seems the |
src/components/Composer/index.js
Outdated
@@ -128,6 +128,7 @@ class Composer extends React.Component { | |||
this.handleWheel = this.handleWheel.bind(this); | |||
this.putSelectionInClipboard = this.putSelectionInClipboard.bind(this); | |||
this.shouldCallUpdateNumberOfLines = this.shouldCallUpdateNumberOfLines.bind(this); | |||
this.updateNumberOfLinesOnLayoutChange = this.updateNumberOfLinesOnLayoutChange(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.
this.updateNumberOfLinesOnLayoutChange = this.updateNumberOfLinesOnLayoutChange(this); | |
this.updateNumberOfLinesOnLayoutChange = this.updateNumberOfLinesOnLayoutChange.bind(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.
Oh, how I forgot it. It is working now @thesahindia , updated.
@Pujan92, you didn't bind the function correctly. I have suggested the change here |
@marcochavezf, any thoughts on #15296 (comment)? |
Yeah, since the - const numberOfLines = getNumberOfLines(this.props.maxLines, lineHeight, paddingTopAndBottom, this.textInput.scrollHeight);
+ const numberOfLines = Math.max(getNumberOfLines(this.props.maxLines, lineHeight, paddingTopAndBottom, this.textInput.scrollHeight), 1); And with that, we won't require the function shouldCallUpdateNumberOfLines. @Pujan92 could you please try that approach? |
@marcochavezf, there is a problem with that solution. Even when composer has multiline text we will be changing the Screen.Recording.2023-02-22.at.11.18.43.PM.mov |
Oh interesting, what if we use the last |
@marcochavezf that also won't work as this happens for the renders and the rerenders and due to scrollHeight |
@marcochavezf, thoughts^? |
Ah I mean if the text is persisted somehow here between renders I think we can also persist the |
Makes sense! cc: @Pujan92 |
@marcochavezf @thesahindia We are persisting |
@Pujan92, we are saving the draft message locally. Can you try doing the same for |
@thesahindia Same will be happens to edit message also, won't it increase the keys tremendously in Onyx if we consider every edit comments too? Screen.Recording.2023-03-02.at.10.05.03.PM.movI tried for report composer with |
I think that's fine?
We are thinking to store cc: @marcochavezf |
1358dfd
to
7949302
Compare
Sorry for the delay (had to go out) @Pujan92, it looks like changing Screen.Recording.2023-03-07.at.11.46.29.PM.mov |
I think using the |
It seems |
I don't know how to proceed now as I am seeing only an option to delay the focus of the input now, the delay is due to the |
I would prefer not using the delay if we can but not sure what else we can do here. |
@marcochavezf, do you have any other ideas? |
Yeah, given that the issue here is an extreme edge case, we should proceed with the best solution so far 👍🏽 |
@marcochavezf, I don't feel good leaving this bug for edit composer while we are fixing the same bug for the main composer. I think we should fix it. Maybe we should open a new issue for edit composer or maybe we should just move to the original solution where we had this minor issue -
|
@Pujan92, please resolve the conflicts. |
@thesahindia resolved. |
Waiting for @marcochavezf thoughts on #15296 (comment) before proceeding with the testing/review. |
Hi @thesahindia, yeah I agree that we should fix all bugs completely, but given that this was an edge case presented during the PR I think the current solution is ok to continue forward. Regarding the solution, I think the solution in this video is better than this one, since from a user perspective the jump looks a bit weirdest than having an edit composer presented in one line (which I think that's not super bad), also seems that @Pujan92 already coded the solution for the jump animation in this PR, no? |
Yes, as we are maintaining the |
@@ -823,6 +835,8 @@ class ReportActionCompose extends React.Component { | |||
setIsFullComposerAvailable={this.setIsFullComposerAvailable} | |||
isComposerFullSize={this.props.isComposerFullSize} | |||
value={this.state.value} | |||
numberOfLines={this.props.numberOfLines} | |||
onNumberOfLinesChange={numberOfLines => this.updateNumberOfLines(numberOfLines)} |
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.
Let's bind updateNumberOfLines
@@ -273,6 +287,8 @@ class ReportActionItemMessageEdit extends React.Component { | |||
}} | |||
selection={this.state.selection} | |||
onSelectionChange={this.onSelectionChange} | |||
numberOfLines={this.props.numberOfLines} | |||
onNumberOfLinesChange={numberOfLines => this.updateNumberOfLines(numberOfLines)} |
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.
Same here
src/components/Composer/index.js
Outdated
@@ -334,11 +343,13 @@ class Composer extends React.Component { | |||
const lineHeight = parseInt(computedStyle.lineHeight, 10) || 20; | |||
const paddingTopAndBottom = parseInt(computedStyle.paddingBottom, 10) | |||
+ parseInt(computedStyle.paddingTop, 10); | |||
const numberOfLines = getNumberOfLines(this.props.maxLines, lineHeight, paddingTopAndBottom, this.textInput.scrollHeight); | |||
const computedNumberOfLines = getNumberOfLines(this.props.maxLines, lineHeight, paddingTopAndBottom, this.textInput.scrollHeight); | |||
const numberOfLines = computedNumberOfLines === 0 ? Math.max(this.props.numberOfLines, 1) : computedNumberOfLines; |
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 think we don't need Math.max
src/components/Composer/index.js
Outdated
@@ -116,7 +124,7 @@ class Composer extends React.Component { | |||
: `${props.value || ''}`; | |||
|
|||
this.state = { | |||
numberOfLines: 1, | |||
numberOfLines: props.numberOfLines || 1, |
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 believe only using props.numberOfLines
will do the job? We are already using 1 for numberOfLines
in default props.
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.
Yes, thanks.
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-03-24.at.1.25.59.AM.mov |
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.
Looks good to me!
cc: @marcochavezf
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.
LGTM, thanks guys!
🚀 Deployed to staging by https://github.com/marcochavezf in version: 1.2.90-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.2.90-7 🚀
|
This PR caused a regression #16931. The use of |
Details
Update numberOfLines when first time the Composer TextInput renders on the screen and the initial numberOfLines is 0
Fixed Issues
$ #15024
PROPOSAL: #15024 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-02-20.at.6.58.44.PM.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android