Skip to content

Commit

Permalink
34265 update emoji offset
Browse files Browse the repository at this point in the history
  • Loading branch information
suneox committed Jan 16, 2024
1 parent f15ed75 commit 2babc2d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ const CONST = {
SMALL_EMOJI_PICKER_SIZE: {
WIDTH: '100%',
},
MENU_POSITION_REPORT_ACTION_COMPOSE_BOTTOM: 83,
NON_NATIVE_EMOJI_PICKER_LIST_HEIGHT: 300,
NON_NATIVE_EMOJI_PICKER_LIST_HEIGHT_WEB: 200,
EMOJI_PICKER_ITEM_HEIGHT: 32,
Expand Down
17 changes: 16 additions & 1 deletion src/components/EmojiPicker/EmojiPickerButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ const propTypes = {
/** Unique id for emoji picker */
emojiPickerID: PropTypes.string,

/** Emoji popup anchor offset shift vertical */
shiftVertical: PropTypes.number,

...withLocalizePropTypes,
};

const defaultProps = {
isDisabled: false,
id: '',
emojiPickerID: '',
shiftVertical: 0,
};

function EmojiPickerButton(props) {
Expand All @@ -49,7 +53,18 @@ function EmojiPickerButton(props) {
return;
}
if (!EmojiPickerAction.emojiPickerRef.current.isEmojiPickerVisible) {
EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor, undefined, () => {}, props.emojiPickerID);
EmojiPickerAction.showEmojiPicker(
props.onModalHide,
props.onEmojiSelected,
emojiPopoverAnchor,
{
horizontal: 'right',
vertical: 'bottom',
shiftVertical: props.shiftVertical,
},
() => {},
props.emojiPickerID,
);
} else {
EmojiPickerAction.emojiPickerRef.current.hideEmojiPicker();
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/calculateAnchorPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function calculateAnchorPosition(anchorComponent: View, anchorOri
if (anchorOrigin?.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP && anchorOrigin?.horizontal === CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT) {
return resolve({horizontal: x, vertical: y + height + (anchorOrigin?.shiftVertical ?? 0)});
}
return resolve({horizontal: x + width, vertical: y});
return resolve({horizontal: x + width, vertical: y + (anchorOrigin?.shiftVertical ?? 0)});
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ function ReportActionCompose({
runOnJS(submitForm)();
}, [isSendDisabled, resetFullComposerSize, submitForm, animatedRef, isReportReadyForDisplay]);

const emojiShiftVertical = useMemo(() => {
const chatItemComposeSecondaryRowHeight = styles.chatItemComposeSecondaryRow.height + styles.chatItemComposeSecondaryRow.marginTop + styles.chatItemComposeSecondaryRow.marginBottom;
const reportActionComposeHeight = styles.chatItemComposeBox.minHeight + chatItemComposeSecondaryRowHeight;
const emojiOffsetWithComposeBox = (styles.chatItemComposeBox.minHeight - styles.chatItemEmojiButton.height) / 2;
return reportActionComposeHeight - emojiOffsetWithComposeBox - CONST.MENU_POSITION_REPORT_ACTION_COMPOSE_BOTTOM;
}, [styles]);

return (
<View style={[shouldShowReportRecipientLocalTime && !lodashGet(network, 'isOffline') && styles.chatItemComposeWithFirstRow, isComposerFullSize && styles.chatItemFullComposeRow]}>
<OfflineWithFeedback pendingAction={pendingAction}>
Expand Down Expand Up @@ -453,6 +460,7 @@ function ReportActionCompose({
onModalHide={focus}
onEmojiSelected={(...args) => composerRef.current.replaceSelectionWithText(...args)}
emojiPickerID={report.reportID}
shiftVertical={emojiShiftVertical}
/>
)}
<SendButton
Expand Down
2 changes: 1 addition & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ const styles = (theme: ThemeColors) =>
createMenuPositionReportActionCompose: (windowHeight: number) =>
({
horizontal: 18 + variables.sideBarWidth,
vertical: windowHeight - 83,
vertical: windowHeight - CONST.MENU_POSITION_REPORT_ACTION_COMPOSE_BOTTOM,
} satisfies AnchorPosition),

createMenuPositionRightSidepane: {
Expand Down

0 comments on commit 2babc2d

Please sign in to comment.