Skip to content

Commit

Permalink
refactor: toggle emoji picker on emoji picker icon clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat-Dabade committed Aug 28, 2024
1 parent 628eaa8 commit 6b4dc17
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
23 changes: 14 additions & 9 deletions app/components/post_draft/draft_input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,19 @@ export default function DraftInput({
inputRef.current?.focus();
}, []);

const handleOpenEmojiPicker = () => {
setIsEmojiPickerOpen(true);
inputRef.current?.setNativeProps({
showSoftInputOnFocus: false,
});
Keyboard.dismiss();
keyboardTracker.current?.pauseTracking(channelId);
inputRef.current?.focus();
const handleToggleEmojiPicker = () => {
if (!isEmojiPickerOpen) {
setIsEmojiPickerOpen(true);
inputRef.current?.setNativeProps({
showSoftInputOnFocus: false,
});
Keyboard.dismiss();
keyboardTracker.current?.pauseTracking(channelId);
inputRef.current?.focus();
return;
}
setIsEmojiPickerOpen(false);
focus();
};

const deleteCharFromCurrentCursorPosition = () => {
Expand Down Expand Up @@ -300,7 +305,7 @@ export default function DraftInput({
updatePostPriority={updatePostPriority}
canShowPostPriority={canShowPostPriority}
focus={focus}
handleOpenEmojiPicker={handleOpenEmojiPicker}
handleToggleEmojiPicker={handleToggleEmojiPicker}
isEmojiPickerOpen={isEmojiPickerOpen}
/>
<SendAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {changeOpacity, makeStyleSheetFromTheme} from '@app/utils/theme';
type Props = {
testID?: string;
disabled?: boolean;
handleOpenEmojiPicker: () => void;
handleToggleEmojiPicker: () => void;
isEmojiPickerOpen: boolean;
}

Expand All @@ -36,7 +36,7 @@ const getStyleSheet = (theme: Theme, isEmojiPickerOpen: boolean) => {
const EmojiQuickAction: React.FC<Props> = ({
testID,
disabled,
handleOpenEmojiPicker,
handleToggleEmojiPicker,
isEmojiPickerOpen,
}) => {
const theme = useTheme();
Expand All @@ -48,7 +48,7 @@ const EmojiQuickAction: React.FC<Props> = ({
<Pressable
testID={actionTestID}
style={style.icon}
onPress={handleOpenEmojiPicker}
onPress={handleToggleEmojiPicker}
>
<CompassIcon
name='emoticon-happy-outline'
Expand Down
6 changes: 3 additions & 3 deletions app/components/post_draft/quick_actions/quick_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Props = {
postPriority: PostPriority;
updatePostPriority: (postPriority: PostPriority) => void;
focus: () => void;
handleOpenEmojiPicker: () => void;
handleToggleEmojiPicker: () => void;
isEmojiPickerOpen: boolean;
}

Expand All @@ -51,7 +51,7 @@ export default function QuickActions({
postPriority,
updatePostPriority,
focus,
handleOpenEmojiPicker,
handleToggleEmojiPicker,
isEmojiPickerOpen,
}: Props) {
const atDisabled = value[value.length - 1] === '@';
Expand Down Expand Up @@ -89,7 +89,7 @@ export default function QuickActions({
focus={focus}
/>
<EmojiQuickAction
handleOpenEmojiPicker={handleOpenEmojiPicker}
handleToggleEmojiPicker={handleToggleEmojiPicker}
isEmojiPickerOpen={isEmojiPickerOpen}
/>
{isPostPriorityEnabled && canShowPostPriority && (
Expand Down

0 comments on commit 6b4dc17

Please sign in to comment.