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'}), + ) + }) +})