-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[IOS] Text replacement by dot after 2 spaces #39385
Conversation
Hi @gedu! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Could you provide an integration test that demonstrates how this interacts with UIKit? This piece of code is quite complex, and already has to do quite a bit of complex state management (eg see Not updating the attributed string may cause issues if the text completion causes the text input to have to grow over multiple lines. |
@javache Hey, yes I can, is there something already in place for TextInput? |
Unfortunately, I don't think we have any in place right now. You could look at adding them here: https://github.com/facebook/react-native/tree/main/packages/rn-tester/RNTesterIntegrationTests (but this may need some work to support the new architecture). You could also try an rn-tester-e2e test. |
I will try to work on this beginning next week |
I ran into some issues when updating |
I updated my local and seems there were many changes and I need to find a new way to fix this issue, given that seems that isn't working now |
Ok I could find the fix, seems that wasn't a big change after all, but only will work for fabric, but I'm double checking. Now I'm working on the testings |
The integration tests are working on Android, but on iOS getting the text from the Input isn't working. I can add text but later I can't get it back from the Input. Looking into that |
…_17153_text_replacement_dot # Conflicts: # packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
Base commit: e4708d6 |
# Conflicts: # packages/rn-tester/Podfile.lock
@javache I added some tests. What do you think? |
@javache friendly ping |
@javache did you have a chance to look at this? |
hey team - can you merge? would love to get this in my app |
@javache can you take a look at this or ping someone that can help us to review this PR? |
I will fix the conflict soon |
Thanks!!!
…On Fri, Jun 7, 2024 at 6:11 AM edug ***@***.***> wrote:
I will fix the conflict soon
—
Reply to this email directly, view it on GitHub
<#39385 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFJCPNV4IOVRCIFZSEO3FW3ZGGBO3AVCNFSM6AAAAAA4TKBPT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJUGUZDSMRVGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Apologies for the delay here, and thank you for adding the test!! Synchronizing state between JS and native is a really complex part of React Native and introducing new variables like The right fix is probably not in bailing out early inside |
@javache I found the e2e tests were removed, I will remove them from here too: #45032
Yeah, I would have to dig again to remember the exact flow. |
@javache Looking a bit deeper, I found something in the
oldText
When not using value and onChangeText (uncontrolled component), both newText and oldText were the same.
That way it works. This way I don't have to add the new flag What do you think? spaceToReplace.mp4 |
@javache did you have time to look into the new proposal? |
@javache friendly ping |
Does the new proposal makes sense? Looks good? |
@javache can you take a look at my new proposal, I'm not using a new flag |
I'll dedicate time to fixing the conflicts and getting everything sorted |
Thanks for the ping. I'll try to find an owner to help review this internally, as it may be related to other auto-correct issues we've been seeing. |
# Conflicts: # packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm # packages/rn-tester-e2e/tests/helpers/utils.js # packages/rn-tester-e2e/tests/screens/components.screen.js
# Conflicts: # packages/rn-tester/Podfile.lock # packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj # packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js
@javache Awesome, thanks, I pushed the code without the flag and just adding the missing fields, I think I need to clean up a bit more the code |
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 suspect #46970 will fix this
In that change, I tried to avoid filling in specific attributes like this, since their presence is an implementation detail of UITextField
that may change in the future (and I'm not sure that UITextView
and others would have the same). Text
(non-input) we probably don't want these either. Comparison insensitive to default typing attributes helps make this more robust for the future (or... other inputs), but was something we are still planning to add UI tests for internally to catch in future iOS updates if they break things.
NSParagraphStyle
after auto-correction in backing input will also change to non-default version, and alignment and writing direction will resolve from natural to either left or right depending on locale, so this fix would not work as user continues to type.
When I was looking at this, we also had different EventEmitter
attributes often, which we handle now in RCTTextInputComponentView
, but is part of the same class of issue.
Closing this PR in favor of #46970 |
Summary:
Pre-requisite:
This PR addresses several issues:
When using TextInput in an uncontrolled manner, without using the value prop, after entering a letter or word and double-tapping the spacebar, it should now correctly add a "." at the end of the letter or word.
When using TextInput in an uncontrolled manner, without using the value prop, after entering certain letters for text replacement, such as "omw" or "@@" (previously created), it now produces the expected replacements.
Motivation:
From Expensify app: Expensify/App#17153
From discussion on: #27693
Changelog:
[IOS][FIXED] - For uncontrolled TextInput: Double tapping space should add "." and Text Replacement for special characters
Test Plan:
TextInput:
"." shortcut
Pre-requisite:
Ensure that the option "." Shortcut" is enabled in Settings->Keyboard.
Using the
onChangeText
and thevalue
props to set new values:E
then tapping the space 2 times, you should seeE.
Test
then tapping the space 2 times, you should seeTest.
Text Replacement
Pre-requisite:
Create a new Text Replacement inside of Settings -> Keyboard, using symbols: like
@@
->[email protected]
Using the
onChangeText
and thevalue
props to set new values:@@
should be selected and clicking space, the@@
should be replaced by[email protected]
input_space_to_dot_working.mp4