Skip to content

Commit 73b644a

Browse files
Saadnajmiclaude
andcommitted
fix: address PR review comments (round 2)
- Add [macOS iOS] diff tags to getTextStorageForAttributedString in .h and .mm - Add comment in updateProps explaining enableContextMenu → _enableSelection rename - Rename _syncSelectableTextStorage → updateSelectableTextStorage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0aa2f81 commit 73b644a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,14 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
163163
_textView.paragraphAttributes = _paragraphAttributes;
164164

165165
if (newParagraphProps.isSelectable != oldParagraphProps.isSelectable) {
166+
// [macOS Replaced enableContextMenu/disableContextMenu with _enableSelection/_disableSelection
167+
// to swap in a native text view that supports text selection.
166168
if (newParagraphProps.isSelectable) {
167169
[self _enableSelection];
168170
} else {
169171
[self _disableSelection];
170172
}
173+
// macOS]
171174
}
172175

173176
[super updateProps:props oldProps:oldProps];
@@ -180,7 +183,7 @@ - (void)updateState:(const State::Shared &)state oldState:(const State::Shared &
180183
[self setNeedsLayout];
181184

182185
if (_selectableTextView) {
183-
[self _syncSelectableTextStorage];
186+
[self updateSelectableTextStorage];
184187
}
185188
}
186189

@@ -195,7 +198,7 @@ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
195198
[self setNeedsLayout];
196199

197200
if (_selectableTextView) {
198-
[self _syncSelectableTextStorage];
201+
[self updateSelectableTextStorage];
199202
}
200203
}
201204

@@ -249,7 +252,7 @@ - (void)_enableSelection
249252
#endif // macOS]
250253

251254
// Sync text content into the native text view.
252-
[self _syncSelectableTextStorage];
255+
[self updateSelectableTextStorage];
253256

254257
// Swap: remove the default text view, install the selectable one.
255258
[_textView removeFromSuperview];
@@ -280,7 +283,7 @@ - (void)_disableSelection
280283
[_textView setNeedsDisplay];
281284
}
282285

283-
- (void)_syncSelectableTextStorage
286+
- (void)updateSelectableTextStorage
284287
{
285288
if (!_selectableTextView || !_textView.state) {
286289
return;

packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ using RCTTextLayoutFragmentEnumerationBlock =
5959
frame:(CGRect)frame
6060
usingBlock:(RCTTextLayoutFragmentEnumerationBlock)block;
6161

62+
// [macOS iOS
6263
- (NSTextStorage *)getTextStorageForAttributedString:(facebook::react::AttributedString)attributedString
6364
paragraphAttributes:(facebook::react::ParagraphAttributes)paragraphAttributes
6465
size:(CGSize)size;
66+
// macOS iOS]
6567

6668
@end
6769

packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ - (TextMeasurement)_measureTextStorage:(NSTextStorage *)textStorage
438438
return TextMeasurement{{size.width, size.height}, attachments};
439439
}
440440

441+
// [macOS iOS
441442
- (NSTextStorage *)getTextStorageForAttributedString:(AttributedString)attributedString
442443
paragraphAttributes:(ParagraphAttributes)paragraphAttributes
443444
size:(CGSize)size
@@ -449,5 +450,6 @@ - (NSTextStorage *)getTextStorageForAttributedString:(AttributedString)attribute
449450

450451
return textStorage;
451452
}
453+
// macOS iOS]
452454

453455
@end

0 commit comments

Comments
 (0)