-
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: 23886 Composer out focus when the thread has many messages #24369
fix: 23886 Composer out focus when the thread has many messages #24369
Conversation
App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 110 to 114 in 893d943
In ReportActionItemMessageEdit we have the logic to init selection whenever this component is mounted. As the comment, the input will be re-focused after the selections are updated on Safari. So I decide to add the logic to prevent selections init when the main composer is focused.
|
@mollfpr Pls help take a look at my PR when you have time. Thanks |
Sorry for the delay @tienifr. I got sick a few days ago 🙏 I'll complete the review today. Regarding the init selection changes, is that regression from the original solution? |
my original proposal works well on web but on mweb we need to change the code a little more to make it work on Safari. App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 110 to 114 in 893d943
|
@tienifr In mWeb/Safari refresh the page and navigate to the report focusing on the edit composer. Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-08-14.at.21.01.50.mp4 |
Do you think it's the bug? As I can see it happens even on staging |
Previously, it was happening on all platforms. In this PR, it's not changed on mWeb/Safari. I think we can create another issue, specifically for the mWeb/Safari, since it needs more time to debug and search for the solution. |
@mollfpr Is it out of the scope? If so, we should proceed to get this GH done first. |
@mollfpr Yes, we get the same result on this PR and staging |
Thanks @tienifr I'll finish the review now. |
@tienifr Could you check on the mWeb/Safari? It seems the new logic on Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-08-21.at.20.00.29.mp4 |
@mollfpr After merging the newest main, I still face this problem again. I swear it worked before. The problem is on iOS, updating the selections makes the input focus, that why when the edit composer is re-mount, the edit composer is focused again. So I just want to pass the selections into the input only when it's focused. Sorry for this inconvenience |
src/components/Composer/index.js
Outdated
return ( | ||
<> | ||
<RNTextInput | ||
autoComplete="off" | ||
autoCorrect={!Browser.isMobileSafari()} | ||
placeholderTextColor={themeColors.placeholderText} | ||
ref={(el) => (textInput.current = el)} | ||
selection={selection} | ||
selection={isFocused ? selection : null} |
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.
@tienifr Could you make the condition only apply to mobile safari? You said that this happened due to the edit composer being re-mount; why do we need to put the logic in the generic composer component?
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.
Updated! Thanks for your suggestion
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 @tienifr, for the quick update.
It's looking good, but I am trying to understand why we need to put the logic in the generic composer component. Could you explain it?
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.
In the generic composer
we init the selections for the input, if we don't do that, when the input re-mounts, the selection will make the input be re-focused. I also think it's the good place to fix because we can prevent all inputs re-focus unexpectedly
Reviewer Checklist
Screenshots/VideosWeb24369.Web.movMobile Web - Chrome24369.mWeb.Chrome.webmMobile Web - SafariDesktop24369.Desktop.moviOS24369.iOS.mp4Android24369.Android.webm |
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 and tests well 👍
Some suggestion on the tests step. On the step 5, we should provide the way to show the main composer. On the Web/Desktop, we can press/click any other part of the chat, but on the native it's not working the same way.
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.
Hmm, platform specific code is stuff we are actively trying to avoid in this repo as much as possible. I overlooked this when looking at the proposal but it seems like the root cause is within safari handling blurred elements. Do you agree?
@thienlnam The problem here is, on Safari the input will be focused if we update the selection for it. We already mentioned it here App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 120 to 122 in bb2386b
Unfortunately, when the edit composer is out of viewport, it will be re-mounted if users add new message => the edit composer will be focused because it receive the new selection. |
@thienlnam @tienifr Otherwise, we can revert the platform-specific safari, and let's find the fix. I think the original proposal should be fixed on all platforms if we don't have a problem with the selection on safari. |
Should we hold this PR until the |
I didn't change |
Yeah, but that sounds like a Safari specific bug we're making exceptions for
I agree with this - we should be fixing the root cause so we don't continue to add platform specific fixes in the code. Let's Remove the platform specific handling in this PR and merge this - creating another issue to remove the platform specific changes in ReportActionItemEdit |
@mollfpr I removed the platform specific handling. Can you help take a look at my PR? Thanks |
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.
It looks good on all platforms except mWeb/Safari. @tienifr Could you add a note for QA that the test for mWeb/Safari is excluded, and we will create another issue for the mWeb/Safari selection issue?
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.
Great - thank you both
✋ 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/thienlnam in version: 1.3.59-0 🚀
|
🚀 Deployed to staging by https://github.com/thienlnam in version: 1.3.60-0 🚀
|
🚀 Deployed to staging by https://github.com/thienlnam in version: 1.3.60-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.59-5 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.60-3 🚀
|
Details
Fixed Issues
$ #23886
PROPOSAL: #23886 (comment)
Tests
Note: The test for mWeb/Safari is excluded, we will create another issue for the mWeb/Safari issue
Offline tests
Same as above
QA Steps
Note: The test for mWeb/Safari is excluded, we will create another issue for the mWeb/Safari issue
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
Screen.Recording.2023-08-10.at.18.21.12.mov
Mobile Web - Chrome
original-AB65C07F-1DF4-4EA1-BC13-BCEE4CA17EE5.mp4
Mobile Web - Safari
original-12591D72-86BC-42AF-8A9C-40FCDB5AB5CD.mp4
Desktop
desktop-compressed.mov
iOS
Screen.Recording.2023-08-10.at.22.14.42.mov
Android
Screen.Recording.2023-08-10.at.22.16.24.mov