From d17da8474b6aa3985e3a74bc3459b483d23109cd Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 4 Oct 2024 15:31:40 -0500 Subject: [PATCH] Emoji handling nested (#5609) --- src/components/Typography.tsx | 31 +++++++++++++++++++------------ src/view/com/util/ViewHeader.tsx | 2 +- src/view/com/util/text/Text.tsx | 31 ++++++++++++++++++------------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/components/Typography.tsx b/src/components/Typography.tsx index 501e23872f..19eba35fbe 100644 --- a/src/components/Typography.tsx +++ b/src/components/Typography.tsx @@ -53,11 +53,14 @@ export function childIsString( ) } -export function renderChildrenWithEmoji(children: StringChild) { +export function renderChildrenWithEmoji( + children: StringChild, + props: Omit = {}, +) { const normalized = Array.isArray(children) ? children : [children] return ( - + {normalized.map(child => { if (typeof child !== 'string') return child @@ -68,10 +71,12 @@ export function renderChildrenWithEmoji(children: StringChild) { } return child.split(EMOJI).map((stringPart, index) => ( - + {stringPart} {emojis[index] ? ( - + {emojis[index]} ) : null} @@ -163,15 +168,17 @@ export function Text({ } } + const shared = { + uiTextView: true, + selectable, + style: s, + dataSet: Object.assign({tooltip: title}, dataSet || {}), + ...rest, + } + return ( - - {isIOS && emoji ? renderChildrenWithEmoji(children) : children} + + {isIOS && emoji ? renderChildrenWithEmoji(children, shared) : children} ) } diff --git a/src/view/com/util/ViewHeader.tsx b/src/view/com/util/ViewHeader.tsx index 64fa504ebe..1d4cf8ff07 100644 --- a/src/view/com/util/ViewHeader.tsx +++ b/src/view/com/util/ViewHeader.tsx @@ -100,7 +100,7 @@ export function ViewHeader({ ) : null} - + {title} diff --git a/src/view/com/util/text/Text.tsx b/src/view/com/util/text/Text.tsx index 3d885480cc..42ea79b8fb 100644 --- a/src/view/com/util/text/Text.tsx +++ b/src/view/com/util/text/Text.tsx @@ -77,13 +77,16 @@ export function Text({ flattened.fontSize = flattened.fontSize * fonts.scaleMultiplier } + const shared = { + uiTextView: true, + selectable, + style: flattened, + ...props, + } + return ( - - {isIOS && emoji ? renderChildrenWithEmoji(children) : children} + + {isIOS && emoji ? renderChildrenWithEmoji(children, shared) : children} ) } @@ -104,14 +107,16 @@ export function Text({ flattened.fontSize = flattened.fontSize * fonts.scaleMultiplier } + const shared = { + selectable, + style: flattened, + dataSet: Object.assign({tooltip: title}, dataSet || {}), + ...props, + } + return ( - - {isIOS && emoji ? renderChildrenWithEmoji(children) : children} + + {isIOS && emoji ? renderChildrenWithEmoji(children, shared) : children} ) }