@bsky.app/react-native-uitextview 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/RNUITextView.mm +19 -13
- package/package.json +1 -1
package/ios/RNUITextView.mm
CHANGED
|
@@ -135,6 +135,7 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
|
|
|
135
135
|
CFTimeInterval _highlightActivationTime;
|
|
136
136
|
NSUInteger _highlightGeneration;
|
|
137
137
|
BOOL _suppressSelectionChange;
|
|
138
|
+
BOOL _textLayoutNeedsUpdate;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
@@ -224,11 +225,20 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
|
|
|
224
225
|
- (void)layoutSubviews
|
|
225
226
|
{
|
|
226
227
|
[super layoutSubviews];
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
//
|
|
230
|
-
// onTextLayout re-fires with the new line wrapping.
|
|
228
|
+
// Keep the inner view in sync synchronously, like RCTParagraphComponentView.
|
|
229
|
+
// Deferring this to drawRect can leave UITextView at an intermediate width
|
|
230
|
+
// after a rotation because display invalidations may be coalesced.
|
|
231
231
|
if (!CGRectEqualToRect(_textView.frame, _view.frame)) {
|
|
232
|
+
const NSRange savedRange = _textView.selectedRange;
|
|
233
|
+
_suppressSelectionChange = YES;
|
|
234
|
+
_textView.frame = _view.frame;
|
|
235
|
+
if (savedRange.location != NSNotFound &&
|
|
236
|
+
NSMaxRange(savedRange) <= _textView.attributedText.length) {
|
|
237
|
+
_textView.selectedRange = savedRange;
|
|
238
|
+
}
|
|
239
|
+
_suppressSelectionChange = NO;
|
|
240
|
+
|
|
241
|
+
_textLayoutNeedsUpdate = YES;
|
|
232
242
|
[self setNeedsDisplay];
|
|
233
243
|
}
|
|
234
244
|
}
|
|
@@ -244,13 +254,11 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
|
|
|
244
254
|
const auto attrString = _state->getData().attributedString;
|
|
245
255
|
const auto convertedAttrString = RCTNSAttributedStringFromAttributedString(attrString);
|
|
246
256
|
|
|
247
|
-
// Setting attributedText clears any active text selection
|
|
248
|
-
// the
|
|
249
|
-
//
|
|
250
|
-
// response to onSelectionChange doesn't deselect what the user is selecting.
|
|
257
|
+
// Setting attributedText clears any active text selection. Bail out entirely
|
|
258
|
+
// when neither the text nor its layout changed so a JS-side state update made
|
|
259
|
+
// in response to onSelectionChange doesn't deselect what the user is selecting.
|
|
251
260
|
const BOOL textChanged = ![_textView.attributedText isEqualToAttributedString:convertedAttrString];
|
|
252
|
-
|
|
253
|
-
if (!textChanged && !frameChanged) {
|
|
261
|
+
if (!textChanged && !_textLayoutNeedsUpdate) {
|
|
254
262
|
return;
|
|
255
263
|
}
|
|
256
264
|
if (textChanged) {
|
|
@@ -266,9 +274,7 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(RNUITextViewEllipsize
|
|
|
266
274
|
}
|
|
267
275
|
_suppressSelectionChange = NO;
|
|
268
276
|
}
|
|
269
|
-
|
|
270
|
-
_textView.frame = _view.frame;
|
|
271
|
-
}
|
|
277
|
+
_textLayoutNeedsUpdate = NO;
|
|
272
278
|
|
|
273
279
|
if (_activeHighlightGroup != nil) {
|
|
274
280
|
[self updatePressHighlight];
|