Comments (8)
@aureosouza thanks for testing this out.
Currently we don't have capacity to investigate bugs that happens only in the Old Architecture, as our priority is to rollout and stabilize the new one.
If you manage to find the root cause and open a PR, I can help tho make sure it lands.
from react-native.
Newer Version of React Native is Available! | |
---|---|
ℹ️ | You are on a supported minor version, but it looks like there's a newer patch available - 0.75.3. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |
from react-native.
Newer Version of React Native is Available! | |
---|---|
ℹ️ | You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |
from react-native.
@aureosouza thanks for the report! Can you check if the issues exists also in the New Architecture, please?
from react-native.
I also created a new project from scratch on 0.75.3
, tried both old and new architecture, and have a couple of observations to add:
In new architecture on 0.75.3
, pasting text behaves completely differently and text seems to be pasted black, completely ignoring style
. Please note that I'm not pasting rich text. I've tried pasting it to a plain text editor without rich text support, then copied again just to be 100% sure that I'm not pasting rich text, and it is still pasted black.
When NOT on new architecture on 0.75.3
, I had a stranger behavior: the text didn't obey the style regardless of any paste event even when there was no maxLength
support. This is what happens in completely typed text with no pasting involved.
Here is my code:
const [text, setText] = useState('');
const style = text.length >= 200 ? {color: 'red'} : {color: 'green'};
console.log('style', style.color);
...
<ScrollView
contentInsetAdjustmentBehavior="automatic">
<TextInput multiline placeholder="Paste some long text" onChangeText={setText} style={style} />
</ScrollView>
This is the output on a freshly started (just to make sure everything gets reset) app with type only:
The first 200 characters are green, and the rest are red.
After a deep dive into React Native's text handling at iOS side I've stumbled upon that the text is indeed composed of different attributed strings with different colors.
If I change RCTUITextView
's - (void)textDidChange
method to some ugly hack like this:
- (void)textDidChange
{
_textWasPasted = NO;
NSAttributedString *newString = [[NSAttributedString alloc] initWithString:self.attributedText.string attributes:self.defaultTextAttributes];
if(![self.attributedText isEqualToAttributedString:newString]){
self.attributedText = newString;
[self _invalidatePlaceholderVisibility];
}
}
Then the attributes are set correctly, whole text changes to correct color based on style and max length correctly (though placeholder disappears after the whole text is deleted, but this is a proof of concept anyway), and there are no longer fragments of text in different parts. Of course, this is definitely not a solution as we lose rich text support AND a new attributed string is constructed-and-assigned in every single text change.
At this point I don't know what the solution would be, because I can't manipulate entered text before it is entered as it seems to be handled natively and just dispatched a UITextViewTextDidChangeNotification
event which calls textDidChange
.
from react-native.
@cipolleschi I enabled the new arch with bundle install && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
and it seems to be working now for me. But migrating to new arch in prod is not an option currently, we might try to help finding a fix for the old arch
from react-native.
@aureosouza is it only iOS related? can you reproduce it on android?
from react-native.
Related Issues (20)
- ReactContext is getting null value in Android native project. HOT 3
- Extra line wrap on some Android devices on some combinations of lineHeight, letterSpacing and other related properties
- Just a test bug for React Native Dev Tools HOT 2
- [0.75.3] Build failing with: "RNGP - Autolinking: Could not find project.android.packageName in react-native config output!" HOT 13
- reactnative.dev SITE IS DOWN. IT HAS BEEN DOWN FOR MORE THAN 3 HOURS HOT 6
- AlignItems may sometimes become invalid on Android HOT 4
- I can't open the new architecture according to the steps on the official website, on ios and android platforms HOT 6
- Another DevTools Test Issue HOT 2
- Test issue HOT 2
- [id: 'com.facebook.react.settings'] > java.io.UncheckedIOException: HOT 3
- Run-android command is stuck without giving any output HOT 4
- Build failed on android with "Task : android:buildCMakeDebug[arm64-v8a] FAILED" HOT 8
- [Android] Headless Crash `Tried to finish non-existent task with id` HOT 3
- "Cannot find EventEmitter for receivedTouches" error in Android Native UI Component HOT 1
- Swift Package Manager (SPM) does not work with RN 0.75.2 HOT 5
- Error "no implicit conversion of String into Array" in Pod Install after migrating to RN > 0.74 (0.74.0 until 0.75.3) HOT 6
- React Native Library .so files are not fortified HOT 5
- [iOS] Crash in ActionSheetIOS: `attempt to insert nil object from objects`
- error unknown option `--config-cmd' HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native.