From fdb1b579a51a437036a7d9fca1a22a93e35bee76 Mon Sep 17 00:00:00 2001 From: Rishi Balakrishnan Date: Tue, 6 Oct 2026 11:55:24 -0400 Subject: [PATCH] fix(typography): render all text through UITextView so nested text survives on iOS (#205) * fix(richtext): keep hashtags visible in selectable post text on iOS Post detail renders its text selectable, which on iOS uses a UITextView that only keeps UITextView children. Hashtag links did not receive the selectable prop, so they rendered as plain Text and were dropped. Forward selectable to RichTextTag, as mentions and links already do. * fix(typography): render all text through UITextView so nested text survives on iOS Non-selectable Text was rendered as a plain RN Text on iOS. Nested inside selectable text, the native UITextView drops non-UITextView children, so hashtags vanished in post detail. Restore upstream behavior: always render UITextView and let react-native-uitextview choose RN Text vs native nesting. Replaces the RichTextTag selectable forwarding from the previous commit. --- src/components/Typography.tsx | 19 +++-------- src/components/__tests__/Typography.test.tsx | 33 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 src/components/__tests__/Typography.test.tsx diff --git a/src/components/Typography.tsx b/src/components/Typography.tsx index 0ac1f6ce3..5c8db79e3 100644 --- a/src/components/Typography.tsx +++ b/src/components/Typography.tsx @@ -1,4 +1,3 @@ -import {Text as RNText} from 'react-native' import {UITextView} from 'react-native-uitextview' import {logger} from '#/logger' @@ -63,20 +62,12 @@ export function Text({ ...rest, } - if (selectable && ios(true)) { - return ( - - {renderChildrenWithEmoji(children, shared, emoji ?? false, { - allowNestedUITextView: false, - })} - - ) - } - return ( - - {renderChildrenWithEmoji(children, shared, emoji ?? false)} - + + {renderChildrenWithEmoji(children, shared, emoji ?? false, { + allowNestedUITextView: !(selectable && ios(true)), + })} + ) } diff --git a/src/components/__tests__/Typography.test.tsx b/src/components/__tests__/Typography.test.tsx new file mode 100644 index 000000000..678f5cbea --- /dev/null +++ b/src/components/__tests__/Typography.test.tsx @@ -0,0 +1,33 @@ +import type * as ReactNative from 'react-native' +import {render} from '@testing-library/react-native' + +import {Text} from '#/components/Typography' + +const mockUITextView = jest.fn() + +jest.mock('react-native-uitextview', () => { + const {Text: RNText} = jest.requireActual('react-native') + return { + UITextView: (props: {children: React.ReactNode}) => { + mockUITextView(props) + return {props.children} + }, + } +}) + +describe('Typography Text', () => { + beforeEach(() => mockUITextView.mockClear()) + + it('renders non-selectable text through UITextView so it can nest inside selectable text', () => { + render( + + hello #blacksky + , + ) + + expect(mockUITextView).toHaveBeenCalledTimes(2) + expect(mockUITextView).toHaveBeenLastCalledWith( + expect.objectContaining({uiTextView: true, children: '#blacksky'}), + ) + }) +}) -- knotmirror 0.0.1