-
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
Composer: Control selection using setSelection #17687
Conversation
I would highly recommend to run the tests from this PR, as it should cover most edge cases. (Edit: I can also take some time to run these tests if needed, as I am by now quite experiences with the weird bugs that can happen when using SetSelection) Here is a copy of it: Regression tests:Test planHelper list to confirm you ran every test
All platforms, make sure for web to run on every browser (Safari, Chrome, Firefox, Edge): Selection is not reset after selecting an emoji
screen-2022-10-12_01.10.50.mp4Broken emojis are rendered when picked from the picker in a series
screen-2022-10-12_01.35.38.mp4Cursor position is broken
screen-2022-10-12_01.46.21.mp4
Steps.
Expected: it should be at the end of the pasted text. Adding emoji via EmojiPicker in replacement for multiple lines creates a delay before the composer height is calculated.
screen-2022-10-19_01.19.07.mp4Selected Emoji is placed in the wrong position.
[Web] Pasting image does not send the attached text message.
Expected: Pressing send on the attachment modal should first send the text and then the image. (See staging for correct behaviour). There is a delay before Composer expands the height on the web.
screen-2022-11-16_19.39.59.mp4Cursor position is not focused after picking a emoji in Composer.
screen-2023-01-05_00.03.18.mp4Content flashing while pasting
screen-2023-01-05_00.11.41.mp4Edit Message: Copy-pasting is slow.
screen-2023-01-09_16.19.55.mp4Cursor jumping or moving positions after picking emoji.
screen-2023-01-09_16.26.09.mp4Compose text is not cleared after sending the messagebug1-web.mov |
@hannojg That's a LIST. By the time we get to finish testing RN would have fixed the bug and Safari would be awesome 😂. |
Can you please highlight some of those? or you are referring to those in the list? |
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.
Also there are some merge conflicts @s77rt |
Thanks @mountiny! I’ll start testing after the conflict resolved. |
We should test all the bugs from the list over this PR. I tried to capture as much as I could. |
Resolved conflicts. Should be ready for test/review. |
I am just loosely going through a few items of the list, @parasharrajat will probably do a full audit. iOS: Enter multiline text, set the cursor to the top position, scroll down, insert emoji. Bug: text input doesn't scroll up Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-04-25.at.15.49.37.mp4 |
iOS: Inserting an emoji by using the Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-04-25.at.15.59.28.mp4 |
Android: Selection is not reset after inserting an emoji Screen.Recording.2023-04-25.at.16.02.46.mov |
@hannojg Those bugs does not occur with traditional |
@mountiny I was hoping that @hannojg Do you have some comments on those bugs? Or what would you suggest in this case? |
I see, I guess if we can clearly define some problem/ solution for that buggy selection issue, we could get some bigger job running 8k+ and someone will have to fix this in RN eventually :D |
For now, we can close this PR and hold the issue on the main issue. We have been working on the main issue for quite sometime. |
Selection is not reset after selecting an emoji Broken emojis are rendered when picked from the picker in a series Cursor position is broken Adding emoji via EmojiPicker in replacement for multiple lines creates a delay before the composer height is calculated. Selected Emoji is placed in the wrong position. Pasting image does not send the attached text message. There is a delay before Composer expands the height on the web. Cursor position is not focused after picking a emoji in Composer. Content flashing while pasting. Edit Message: Copy-pasting is slow. Cursor jumping or moving positions after picking emoji. Compose text is not cleared after sending the message |
Issue when executing Adding emoji via EmojiPicker in replacement for multiple lines creates a delay before the composer height is calculated. Firefox - Adding emoji from the picker adding a bottom space inside the input.
VideoScreen.Recording.2023-04-26.at.11.35.06.mov |
Issue when executing Selected Emoji is placed in the wrong position. Android - The selection selects the previous letter and will select the previous text
VideoScreen_Recording_20230426_150138_New.Expensify.mp4Note: It's only reproduce when select 3 or more letter |
I think the other issue is also following the @mollfpr Thanks for testing! The results are not that bad 😅 but Android selection issue is so concerning. Can you please add a video for falling |
Simulator.Screen.Recording.-.iPhone.14.-.2023-04-26.at.20.42.18.mp4 |
Yes. Based on your last comment, I thought we don't have a clear solution for moving forward. I suggested this as we have done extensive research and testing on the other issue. We are even exploring an upstream solution. Unless we have a different approach, we should not replicate the effort. |
@mollfpr Ah this requires a selection range. Unfortunately both Android and iOS are buggy using selection range. |
@parasharrajat Yes sadly we don't have a clear solution. I believe the other issue is only for Android. I think we should do what @mountiny proposed, raise a new clear P/S statement in an attempt to fix the buggy selection prop on RN for both Android and iOS. |
The issue title is misleading. But all the issues are tested and perfected on each platform before we merge PRs. So I tested that PR on all platforms and make sure that it works. This pushed us to get a common solution for all platforms.
Sounds good. |
There is not that many fails, but lets go with fixing this upstream. Anyone is willing to take this on? I will close this PR after |
@mountiny I will but can I get a clarification on the plan, is it:
Or we will be taking this to RN first? |
Hey, Hanno here from Margelo 👋 I am here to help find a solid fix for this issue, also in hindsight of my other PR #11684. I am ready to make a proposal in some appropriate place, that will handle all the issues discussed. I just want to note that the proposal likely won't be a upstream fix, as I figured that some of the problems are simply not fixable upstream (there exists no solution that is working generically enough, to suite all use cases with inputs in react native). My proposal would very likely include creating an own native component for TextInput on android (which will extend/inherit the existing react native's text input). |
Alright, I think we could go deep haha but what I suggest then @hannojg is to create a P/S in the #expensify-open-source channel to explain what problems we are solving (this should be quite straightforward we have real bugs right here haha) and then in the threads also please dont forget to mention why its not fixable upstream ideally with backing of some exisitng tries from other people. I am sure some people will come and ask "are you sure" so adding osmething like this will help with it. Would @s77rt and @hannojg be interested in working on this a bit together? Not sure how you like to work but there could be help with debugging nad testing for sure :) That do you think? |
@hannojg I wouldn't be too surprised if the upstream fix is a lot of work but this was actually working on RN, so maybe we can just drop the "features" that broke it? Also please note that we are looking to fix the buggy selection on iOS too (which would also require upstream changes) I'm interested on working on this as @mountiny suggested, let me know what do you think |
Can we move this discussion to Slack? I think that would be easier (the problem solution statement can be nailed later, I will close this Pr for now) |
@hannojg
Details
Instead of controlling the selection the traditional way (passing
selection
prop) which is always render dependent and is so buggy on RN especially for Android. We are going to control the selection directly using an independent and render free method which issetSelection
for Native andsetSelectionRange
for Web. We we will be using our setSelection library for that.Fixed Issues
$ #12854
PROPOSAL: #12854 (comment)
Tests
Hi there
Hi
andthere
:wave:
Hi
andthere
Offline tests
n/a
QA Steps
Hi there
Hi
andthere
:wave:
Hi
andthere
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
web.mp4
Mobile Web - Chrome
mweb-chrome.mp4
Mobile Web - Safari
mweb-safari.mp4
Desktop
desktop.mp4
iOS
ios.mp4
Android
android.mp4