-
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
fix: cursor issue starting on left of text #25528
Conversation
@@ -124,16 +125,18 @@ function ReportActionItemMessageEdit(props) { | |||
}, [isFocused]); | |||
|
|||
useEffect(() => { | |||
// For mobile Safari, updating the selection prop on an unfocused input will cause it to automatically gain focus | |||
// For every platform execept Android, updating the selection prop on an unfocused input will cause it to automatically gain focus |
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.
Could you compare it with the implementation in ReportActionCompose.js
?
App/src/pages/home/report/ReportActionCompose.js
Lines 231 to 234 in dd0d98f
selection: { | |
start: isMobileSafari && !this.shouldAutoFocus ? 0 : props.comment.length, | |
end: isMobileSafari && !this.shouldAutoFocus ? 0 : props.comment.length, | |
}, |
Maybe apart from the setDraft/setSelection we need to init the selection per platform too?
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 i can see in ReportActionCompose.js
its called directly during initialisation of the state. And what we are trying to achieve is different as we want to call this after the comment state is initialised and also handle few of the browser related issues like modal focus trap
etc.
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.
@robertKozik Waiting for your reply here.
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.
What I was considering is the possibility of limiting the scope of the setDraft/setSelection actions to mobile Safari and Chrome, where we would initialize the selection as in the composer. This approach could look like this:
On mobile Safari: Initialize the selection as 0 and then update it using setDraft/setSelection.
On other platforms: Initialize the selection with the draft's length and avoid updating it using setDraft/setSelection.
I didn;t test it - just throwing ideas as in ReportActionCompose.js
we don't have a problem with the cursor
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.
@robertKozik Tried your solution it works as we expected.
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.
Finishing up the PR now.
@robertKozik Please 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] |
Reviewer Checklist
Screenshots/VideosWebWEB.movMobile Web - Chromeandroid.-.web.movMobile Web - Safariios.-.web.movDesktopScreen.Recording.2023-09-01.at.13.16.06.moviOSios.native.movAndroidandroid.-.native.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.
Few questions ^^ Please address them when you will be able to
}; | ||
|
||
const getInitialSelection = () => { | ||
const length = getInitialDraft().length; |
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.
Can we move this calculation after the isMobileSafari
if condition? We don't need to calculate it for safari, so let's calculate it only for other platforms
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.
Moved after the isMobileSafari check.
@@ -93,17 +94,28 @@ function ReportActionItemMessageEdit(props) { | |||
const {translate} = useLocalize(); | |||
const {isKeyboardShown} = useKeyboardState(); | |||
const {isSmallScreenWidth} = useWindowDimensions(); | |||
const isMobileSafari = Browser.isMobileSafari(); |
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.
Can we move it outside the functional component? It won't change in runtime. Simmilar approach can be seen in ComposerWithSuggestions.js
file
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.
Thanks for this insight moved it outside the component.
@@ -139,7 +153,7 @@ function ReportActionItemMessageEdit(props) { | |||
// to prevent the main composer stays hidden until we swtich to another chat. | |||
ComposerActions.setShouldShowComposeInput(true); | |||
}; | |||
}, [props.action.reportActionID]); | |||
}, [props.action.reportActionID, isMobileSafari]); |
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.
isMobileSafari
const won't change during the lifecycle of the component. Do we need this to make lint happy?
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 lint 😢
I have added the changes and also added comments. Please check. |
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.
Looking good
@cristipaval as we have ongoing merge freeze (info) what do you think about urgency of this PR? For me it can wait until the freeze will be canceled |
yes this could definitely wait |
@jeet-dhandha Can you please follow the instructions from slack, i.e. update the PR with the latest main and re-test it? Thanks |
@robertKozik Merged main and checked its working and no conflicts were also there. |
Android VideoDEv.mp4 |
Looks good on my end as well. @cristipaval, the floor is yours. However, I would appreciate it if we could hold off on merging until tomorrow. I've already had several PRs merged from the HOLD status, and it would be great if we could space them out a bit 🙇🏼 |
Ok, I'll merge it tomorrow then. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/cristipaval in version: 1.3.69-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.69-2 🚀
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 1.3.70-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.70-8 🚀
|
Details
setDraft
function only for Mobile Safari and Mobile chrome as for other platforms it was creating a side effect due to which cursor is not set to the right for Android Only.Fixed Issues
$ #24157
PROPOSAL: #24157 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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
EditText-Web-min.mp4
Mobile Web - Chrome
EditText-Mobile-Chrome-min.mp4
Mobile Web - Safari
EditText-Mobile-Safari-min.mp4
Desktop
EditText-Desktop-min.mp4
iOS
EditText-iOS-min.mp4
Android
EditText-Android-min.mp4