Skip to content

Commit d3fed42

Browse files
authored
fix: mount the emoji searchbar only when it's visible (#7405)
1 parent cbaafdc commit d3fed42

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

app/containers/MessageComposer/MessageComposer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export const MessageComposer = ({
246246
<MessageComposerContent
247247
recordingAudio={recordingAudio}
248248
action={action}
249+
showEmojiSearchbar={showEmojiSearchbar}
249250
composerInputComponentRef={composerInputComponentRef}
250251
composerInputRef={composerInputRef}
251252
onLayout={handleLayout}>

app/containers/MessageComposer/components/EmojiSearchbar.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import { useEmojiKeyboard } from '../hooks/useEmojiKeyboard';
1818

1919
const BUTTON_HIT_SLOP = { top: 4, right: 4, bottom: 4, left: 4 };
2020

21-
export const EmojiSearchbar = (): ReactElement | null => {
21+
export const EmojiSearchbar = (): ReactElement => {
2222
'use memo';
2323

2424
const { colors } = useTheme();
2525
const [searchText, setSearchText] = useState<string>('');
26-
const { showEmojiSearchbar, closeEmojiSearchbar } = useEmojiKeyboard();
26+
const { closeEmojiSearchbar } = useEmojiKeyboard();
2727
const { onEmojiSelected } = useContext(MessageInnerContext);
2828
const { frequentlyUsed } = useFrequentlyUsedEmoji(true);
2929
const [emojis, setEmojis] = useState<IEmoji[]>([]);
@@ -41,10 +41,6 @@ export const EmojiSearchbar = (): ReactElement | null => {
4141

4242
const renderItem = ({ item }: { item: IEmoji }) => <PressableEmoji emoji={item} onPress={handleEmojiSelected} />;
4343

44-
if (!showEmojiSearchbar) {
45-
return null;
46-
}
47-
4844
return (
4945
<View style={{ backgroundColor: colors.surfaceLight }}>
5046
<FlatList

app/containers/MessageComposer/components/MessageComposerContent.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ import { MESSAGE_COMPOSER_EXIT_FOCUS_NATIVE_ID } from '../../../lib/constants/ac
1717
interface MessageComposerContentProps {
1818
recordingAudio: boolean;
1919
action: TMessageAction | undefined;
20+
showEmojiSearchbar: boolean;
2021
composerInputComponentRef: RefObject<IComposerInput>;
2122
composerInputRef: RefObject<any>;
2223
children?: ReactElement | null;
2324
onLayout: (event: LayoutChangeEvent) => void;
2425
}
2526

2627
export const MessageComposerContent = memo<MessageComposerContentProps>(
27-
({ recordingAudio, action, composerInputComponentRef, composerInputRef, children, onLayout }) => {
28+
({ recordingAudio, action, showEmojiSearchbar, composerInputComponentRef, composerInputRef, children, onLayout }) => {
2829
'use memo';
2930

3031
const { colors } = useTheme();
@@ -47,7 +48,7 @@ export const MessageComposerContent = memo<MessageComposerContentProps>(
4748
</View>
4849
<Quotes />
4950
<Toolbar />
50-
<EmojiSearchbar />
51+
{showEmojiSearchbar ? <EmojiSearchbar /> : null}
5152
<SendThreadToChannel />
5253
{children}
5354
</View>

0 commit comments

Comments
 (0)