-
Notifications
You must be signed in to change notification settings - Fork 3k
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: auto focus and scroll to bottom on large-text in composer #28790
Conversation
Reviewer Checklist
Screenshots/VideosWebchrome-desktop-2023-10-10_17.33.03.mp4Mobile Web - Chromeandroid-chrome.mp4Mobile Web - Safariios-safari-2023-10-13_16.09.20.mp4Desktopmac-desktop-2023-10-13_16.06.20.mp4iOSios-native-2023-10-13_16.35.31.mp4Androidandroid-native.mp4 |
@jeet-dhandha I'm still getting a delay before the composer scrolls to the bottom, presumably because you're wrapping with |
|
||
InteractionManager.runAfterInteractions(() => { | ||
updateMultilineInputRange(textInputRef.current); | ||
focus(); // This will focus the composer after its fully rendered. |
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.
Unsure why we need to force focus 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.
autoFocus={shouldAutoFocusWithLongText} |
If you check above line of code we are disabling autoFocus as we wan't to focus manually after scrollHeight and selection are updated.
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.
So without that, the selection wouldn't be set to the end, is that what you mean? Or what side-effect is there if we don't add that?
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.
Screen.Recording.2023-10-06.at.3.10.04.PM.mov
Without that Composer won't get Focused. As you can see the Cursor isn't there in the end.
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.
Sorry this still isn't really making sense to me. If I remove your change to autoFocus
and just have a simple useEffect
that runs updateMultilineInputRange
, it works fine (on desktop at least). I'm struggling to understand the reason why all this extra logic is necessary 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.
Did you check out my video @jjcoffee ?
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.
Lets have a quick chat in Slack here its harder to chat.
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.
@jeet-dhandha Yes, is that with autoFocus
set back to shouldAutoFocus
? I don't get the same behaviour if so...
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.
The original issue also doesn't show any problem with focusing on the composer. That's why I'm quite sceptical about adding extra focus calls here!
@jeet-dhandha Can you please update the test steps to clarify that the text has to be long enough to make the scrollbar appear? It's also probably better to start with entering a long text and then refreshing, otherwise the steps are a bit confusing. |
@jeet-dhandha One last thing, can you make sure the screenshots follow the test steps? Not all of them seem to have a long enough text. |
Updated Test's and Videos for |
Let me check this one. |
True Enough @jjcoffee . WebScreen.Recording.2023-10-05.at.10.24.29.PM.mov |
Also updated comment for manual |
Video for difference between with
|
@jeet-dhandha My point was that if I remove all of your code (including the |
WTH 😵💫 it was not working previously as the scroll to bottom animation was coming. But now its working probably due to the removal on @jjcoffee Removing all the unnecessary code. |
@jjcoffee Please review last time 😄 |
@jjcoffee If possible lets complete it before 3 day end. |
@@ -445,6 +448,17 @@ function ComposerWithSuggestions({ | |||
textInputRef.current.blur(); | |||
}, []); | |||
|
|||
useEffect(() => { | |||
// Initial focus ref to prevent unneccessary focus after first render. | |||
if (initialFocusedRef.current || isNativeApp || !shouldAutoFocus) { |
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 don't think initialFocusedRef
is needed anymore since we removed focus calls.
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 don't think the isNativeApp
check is really necessary here either. Also not sure if you considered under what cases shouldAutoFocus
would be false and if we'd not want to scroll to the bottom? It seems to me like we always want to be scrolled to the bottom, but I could be missing some obvious case!
@jeet-dhandha As it stands, it doesn't look like we scroll to the bottom on mWeb which I don't think makes sense as you most likely want to continue from the end of your last message, rather than the top (even if we're not focused on the composer!). |
Please check now. @jjcoffee |
I mistakenly added screenshot of |
Hmm I see what you mean, can you check the behaviour? |
Yes it focuses it. |
There's a hack which i think we can use, but i don't recommend it. Screen.Recording.2023-10-11.at.8.08.52.PM.mov |
Hmm so I think we'll probably need to do the same as on the issue that introduced Note there's a very old RN issue from 2020 related to this. We could open an issue to see if anyone has a proposal to fix that issue as it would unlock the fix for both this and all pages that rely on |
@jeet-dhandha Could you ensure that iOS doesn't focus on composer, maybe by adding a |
Added Screen.Recording.2023-10-12.at.11.10.11.PM.mov |
@jeet-dhandha Sweet, thanks! You have conflicts, can you merge main? Hopefully we can get this completed today finally 😄 |
@jeet-dhandha Can you also update the PR description and tests to reflect the latest changes, i.e. we scroll to bottom on all platforms except iOS which we are not supporting for now. |
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
…ons.js Co-authored-by: Joel Davies <[email protected]>
Done @jjcoffee |
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!
@jeet-dhandha Oh actually could you update the description per this comment? |
Updated Description and tests. |
✋ 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/nkuoch in version: 1.3.86-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.86-5 🚀
|
Details
iOS
, as we don't have a good solution for it.Fixed Issues
$ #27153
PROPOSAL: #27153 (comment)
Tests
iOS
.Offline tests
iOS
.QA Steps
iOS
.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
Web.mp4
Mobile Web - Chrome
MobileChrome.mov
Mobile Web - Safari
MobileSafari.mov
Desktop
Desktop.mp4
iOS
iOS.mov
Android
Android.mov