Skip to content

Commit 4a8b431

Browse files
authored
Merge pull request #22984 from hoangzinh/df/22214
Fix the emoji picker does not close when editing message is deleted
2 parents 6bcd184 + 2906498 commit 4a8b431

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/components/EmojiPicker/EmojiPickerButton.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@ const propTypes = {
1717
/** Id to use for the emoji picker button */
1818
nativeID: PropTypes.string,
1919

20+
/**
21+
* ReportAction for EmojiPicker.
22+
*/
23+
reportAction: PropTypes.shape({
24+
reportActionID: PropTypes.string,
25+
}),
26+
2027
...withLocalizePropTypes,
2128
};
2229

2330
const defaultProps = {
2431
isDisabled: false,
2532
nativeID: '',
33+
reportAction: {},
2634
};
2735

2836
function EmojiPickerButton(props) {
@@ -33,7 +41,7 @@ function EmojiPickerButton(props) {
3341
ref={(el) => (emojiPopoverAnchor = el)}
3442
style={({hovered, pressed}) => [styles.chatItemEmojiButton, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed))]}
3543
disabled={props.isDisabled}
36-
onPress={() => EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor)}
44+
onPress={() => EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor, undefined, () => {}, props.reportAction)}
3745
nativeID={props.nativeID}
3846
accessibilityLabel={props.translate('reportActionCompose.emoji')}
3947
>

src/pages/home/report/ReportActionItemMessageEdit.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import useLocalize from '../../../hooks/useLocalize';
3434
import useKeyboardState from '../../../hooks/useKeyboardState';
3535
import useWindowDimensions from '../../../hooks/useWindowDimensions';
3636
import useReportScrollManager from '../../../hooks/useReportScrollManager';
37+
import * as EmojiPickerAction from '../../../libs/actions/EmojiPickerAction';
3738

3839
const propTypes = {
3940
/** All the data of the action */
@@ -118,16 +119,17 @@ function ReportActionItemMessageEdit(props) {
118119
});
119120

120121
return () => {
121-
// Skip if this is not the focused message so the other edit composer stays focused
122-
if (!isFocusedRef.current) {
122+
// Skip if this is not the focused message so the other edit composer stays focused.
123+
// In small screen devices, when EmojiPicker is shown, the current edit message will lose focus, we need to check this case as well.
124+
if (!isFocusedRef.current && !EmojiPickerAction.isActiveReportAction(props.action.reportActionID)) {
123125
return;
124126
}
125127

126128
// Show the main composer when the focused message is deleted from another client
127129
// to prevent the main composer stays hidden until we swtich to another chat.
128130
ComposerActions.setShouldShowComposeInput(true);
129131
};
130-
}, []);
132+
}, [props.action.reportActionID]);
131133

132134
/**
133135
* Save the draft of the comment. This debounced so that we're not ceaselessly saving your edit. Saving the draft
@@ -346,6 +348,7 @@ function ReportActionItemMessageEdit(props) {
346348
onModalHide={() => InteractionManager.runAfterInteractions(() => textInputRef.current.focus())}
347349
onEmojiSelected={addEmojiToTextBox}
348350
nativeID={emojiButtonID}
351+
reportAction={props.action}
349352
/>
350353
</View>
351354

0 commit comments

Comments
 (0)