Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix iOS composer text getting cut off (#2764)

* patch react-native textinput

* cleanup patchfile

authored by

Hailey and committed by
GitHub
39b4081c 52f57b3a

+83 -3
+78 -3
patches/react-native+0.73.2.patch
··· 2 2 index 9dca6a5..090bda5 100644 3 3 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm 4 4 +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm 5 - @@ -266,11 +266,10 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo 6 - 5 + @@ -266,11 +266,10 @@ - (void)textViewDidChange:(__unused UITextView *)textView 6 + 7 7 - (void)textViewDidChangeSelection:(__unused UITextView *)textView 8 8 { 9 9 - if (_lastStringStateWasUpdatedWith && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { ··· 14 14 - _lastStringStateWasUpdatedWith = _backedTextInputView.attributedText; 15 15 [self textViewProbablyDidChangeSelection]; 16 16 } 17 - 17 + 18 + diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm 19 + index 1f06b79..ab458f3 100644 20 + --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm 21 + +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm 22 + @@ -87,7 +87,7 @@ - (void)invalidateContentSize 23 + return; 24 + } 25 + 26 + - CGSize maximumSize = self.layoutMetrics.frame.size; 27 + + CGSize maximumSize = self.layoutMetrics.contentFrame.size; 28 + 29 + if (_maximumNumberOfLines == 1) { 30 + maximumSize.width = CGFLOAT_MAX; 31 + @@ -158,6 +158,8 @@ - (void)uiManagerWillPerformMounting 32 + [attributedText insertAttributedString:propertyAttributedText atIndex:0]; 33 + } 34 + 35 + + [self postprocessAttributedText:attributedText]; 36 + + 37 + NSAttributedString *newAttributedText; 38 + if (![_previousAttributedText isEqualToAttributedString:attributedText]) { 39 + // We have to follow `set prop` pattern: 40 + @@ -191,6 +193,52 @@ - (void)uiManagerWillPerformMounting 41 + }]; 42 + } 43 + 44 + +- (void)postprocessAttributedText:(NSMutableAttributedString *)attributedText 45 + +{ 46 + + __block CGFloat maximumLineHeight = 0; 47 + + 48 + + [attributedText enumerateAttribute:NSParagraphStyleAttributeName 49 + + inRange:NSMakeRange(0, attributedText.length) 50 + + options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired 51 + + usingBlock:^(NSParagraphStyle *paragraphStyle, __unused NSRange range, __unused BOOL *stop) { 52 + + if (!paragraphStyle) { 53 + + return; 54 + + } 55 + + 56 + + maximumLineHeight = MAX(paragraphStyle.maximumLineHeight, maximumLineHeight); 57 + + }]; 58 + + 59 + + if (maximumLineHeight == 0) { 60 + + // `lineHeight` was not specified, nothing to do. 61 + + return; 62 + + } 63 + + 64 + + __block CGFloat maximumFontLineHeight = 0; 65 + + 66 + + [attributedText enumerateAttribute:NSFontAttributeName 67 + + inRange:NSMakeRange(0, attributedText.length) 68 + + options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired 69 + + usingBlock:^(UIFont *font, NSRange range, __unused BOOL *stop) { 70 + + if (!font) { 71 + + return; 72 + + } 73 + + 74 + + if (maximumFontLineHeight <= font.lineHeight) { 75 + + maximumFontLineHeight = font.lineHeight; 76 + + } 77 + + }]; 78 + + 79 + + if (maximumLineHeight < maximumFontLineHeight) { 80 + + return; 81 + + } 82 + + 83 + + CGFloat baseLineOffset = maximumLineHeight / 2.0 - maximumFontLineHeight / 2.0; 84 + + 85 + + [attributedText addAttribute:NSBaselineOffsetAttributeName 86 + + value:@(baseLineOffset) 87 + + range:NSMakeRange(0, attributedText.length)]; 88 + +} 89 + + 90 + #pragma mark - 91 + 92 + - (NSAttributedString *)measurableAttributedText
+5
patches/react-native+0.73.2.patch.md
··· 1 + # TextInput Patch 2 + 3 + Patching `RCTBaseTextShadowInput.mm` from https://github.com/facebook/react-native/pull/38359. This fixes some text 4 + getting cut off inside the composer. This was merged in December, so we should be able to remove this patch when RN 5 + ships the next release.