fix emoji click on button while open closes it

Fixes #1980
pull/1992/head
Audric Ackermann 4 years ago
parent 738fc63a49
commit dfa04c68f4
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -9,6 +9,7 @@ const MessageStatusSendingContainer = styled.div`
align-self: flex-end; align-self: flex-end;
margin-bottom: 2px; margin-bottom: 2px;
margin-inline-start: 5px; margin-inline-start: 5px;
cursor: pointer;
`; `;
const MessageStatusSending = () => { const MessageStatusSending = () => {

@ -109,18 +109,21 @@ const StartRecordingButton = (props: { onClick: () => void }) => {
); );
}; };
const ToggleEmojiButton = (props: { onClick: () => void }) => { const ToggleEmojiButton = React.forwardRef<HTMLDivElement, { onClick: () => void }>(
return ( (props, ref) => {
<SessionIconButton return (
iconType="emoji" <SessionIconButton
backgroundColor="var(--color-compose-view-button-background)" iconType="emoji"
iconSize={'huge2'} ref={ref}
borderRadius="300px" backgroundColor="var(--color-compose-view-button-background)"
iconPadding="6px" iconSize={'huge2'}
onClick={props.onClick} borderRadius="300px"
/> iconPadding="6px"
); onClick={props.onClick}
}; />
);
}
);
const SendMessageButton = (props: { onClick: () => void }) => { const SendMessageButton = (props: { onClick: () => void }) => {
return ( return (
@ -205,7 +208,8 @@ const getDefaultState = (newConvoId?: string) => {
class SessionCompositionBoxInner extends React.Component<Props, State> { class SessionCompositionBoxInner extends React.Component<Props, State> {
private readonly textarea: React.RefObject<any>; private readonly textarea: React.RefObject<any>;
private readonly fileInput: React.RefObject<HTMLInputElement>; private readonly fileInput: React.RefObject<HTMLInputElement>;
private emojiPanel: any; private readonly emojiPanel: any;
private readonly emojiPanelButton: any;
private linkPreviewAbortController?: AbortController; private linkPreviewAbortController?: AbortController;
private container: any; private container: any;
private readonly mentionsRegex = /@\uFFD205[0-9a-f]{64}\uFFD7[^\uFFD2]+\uFFD2/gu; private readonly mentionsRegex = /@\uFFD205[0-9a-f]{64}\uFFD7[^\uFFD2]+\uFFD2/gu;
@ -219,7 +223,8 @@ class SessionCompositionBoxInner extends React.Component<Props, State> {
this.fileInput = React.createRef(); this.fileInput = React.createRef();
// Emojis // Emojis
this.emojiPanel = null; this.emojiPanel = React.createRef();
this.emojiPanelButton = React.createRef();
autoBind(this); autoBind(this);
this.toggleEmojiPanel = debounce(this.toggleEmojiPanel.bind(this), 100); this.toggleEmojiPanel = debounce(this.toggleEmojiPanel.bind(this), 100);
} }
@ -271,7 +276,10 @@ class SessionCompositionBoxInner extends React.Component<Props, State> {
} }
private handleClick(e: any) { private handleClick(e: any) {
if (this.emojiPanel && this.emojiPanel.contains(e.target)) { if (
(this.emojiPanel?.current && this.emojiPanel.current.contains(e.target)) ||
(this.emojiPanelButton?.current && this.emojiPanelButton.current.contains(e.target))
) {
return; return;
} }
@ -421,11 +429,13 @@ class SessionCompositionBoxInner extends React.Component<Props, State> {
{this.renderTextArea()} {this.renderTextArea()}
</div> </div>
{typingEnabled && <ToggleEmojiButton onClick={this.toggleEmojiPanel} />} {typingEnabled && (
<ToggleEmojiButton ref={this.emojiPanelButton} onClick={this.toggleEmojiPanel} />
)}
<SendMessageButton onClick={this.onSendMessage} /> <SendMessageButton onClick={this.onSendMessage} />
{typingEnabled && ( {typingEnabled && (
<div ref={ref => (this.emojiPanel = ref)} onKeyDown={this.onKeyDown} role="button"> <div ref={this.emojiPanel} onKeyDown={this.onKeyDown} role="button">
{showEmojiPanel && ( {showEmojiPanel && (
<SessionEmojiPanel onEmojiClicked={this.onEmojiClick} show={showEmojiPanel} /> <SessionEmojiPanel onEmojiClicked={this.onEmojiClick} show={showEmojiPanel} />
)} )}

@ -12,7 +12,7 @@ interface SProps extends SessionIconProps {
margin?: string; margin?: string;
} }
const SessionIconButtonInner = (props: SProps) => { const SessionIconButtonInner = React.forwardRef<HTMLDivElement, SProps>((props, ref) => {
const { const {
iconType, iconType,
iconSize, iconSize,
@ -40,6 +40,7 @@ const SessionIconButtonInner = (props: SProps) => {
<div <div
className={classNames('session-icon-button', iconSize, isSelected ? 'no-opacity' : '')} className={classNames('session-icon-button', iconSize, isSelected ? 'no-opacity' : '')}
role="button" role="button"
ref={ref}
onClick={clickHandler} onClick={clickHandler}
style={{ display: isHidden ? 'none' : 'flex', margin: margin ? margin : '' }} style={{ display: isHidden ? 'none' : 'flex', margin: margin ? margin : '' }}
> >
@ -58,6 +59,6 @@ const SessionIconButtonInner = (props: SProps) => {
{Boolean(notificationCount) && <SessionNotificationCount count={notificationCount} />} {Boolean(notificationCount) && <SessionNotificationCount count={notificationCount} />}
</div> </div>
); );
}; });
export const SessionIconButton = React.memo(SessionIconButtonInner, _.isEqual); export const SessionIconButton = React.memo(SessionIconButtonInner, _.isEqual);

@ -53,7 +53,6 @@ async function unsendMessagesForEveryone(
// sending to recipient all the messages separately for now // sending to recipient all the messages separately for now
await Promise.all( await Promise.all(
unsendMsgObjects.map(unsendObject => { unsendMsgObjects.map(unsendObject => {
console.warn('sending unsend message', unsendObject);
getMessageQueue() getMessageQueue()
.sendToGroup(unsendObject, undefined, new PubKey(destinationId)) .sendToGroup(unsendObject, undefined, new PubKey(destinationId))
.catch(window?.log?.error); .catch(window?.log?.error);

Loading…
Cancel
Save