Skip to content

Commit

Permalink
fit the emoji panel to message tag
Browse files Browse the repository at this point in the history
  • Loading branch information
VirajDilshanKumarage committed Apr 17, 2024
1 parent b470c20 commit 9f7f3cf
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions react/features/chat/components/web/ChatInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import data from '@emoji-mart/data';
import Picker from '@emoji-mart/react';
import React, { Component, RefObject } from 'react';
import { WithTranslation } from 'react-i18next';
import { connect } from 'react-redux';
Expand All @@ -10,7 +12,6 @@ import Button from '../../../base/ui/components/web/Button';
import Input from '../../../base/ui/components/web/Input';
import { areSmileysDisabled } from '../../functions';

import SmileysPanel from './SmileysPanel';

/**
* The type of the React {@code Component} props of {@link ChatInput}.
Expand Down Expand Up @@ -64,9 +65,11 @@ class ChatInput extends Component<IProps, IState> {

state = {
message: '',
messages: [],
showSmileysPanel: false
};


/**
* Initializes a new {@code ChatInput} instance.
*
Expand Down Expand Up @@ -109,8 +112,10 @@ class ChatInput extends Component<IProps, IState> {
if (prevProps._privateMessageRecipientId !== this.props._privateMessageRecipientId) {
this._textArea?.current?.focus();
}

}


/**
* Implements React's {@link Component#render()}.
*
Expand All @@ -123,11 +128,16 @@ class ChatInput extends Component<IProps, IState> {
<div id = 'chat-input' >
{!this.props._areSmileysDisabled && this.state.showSmileysPanel && (
<div
className = 'smiley-input'>
className = 'smiley-input' >
<div
className = 'smileys-panel' >
<SmileysPanel
onSmileySelect = { this._onSmileySelect } />

<Picker
data = { data }

Check failure on line 136 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
onEmojiSelect = { this.addEmoji }

Check failure on line 137 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

Handler function for onEmojiSelect prop key must be a camelCase name beginning with '_on' only

Check failure on line 137 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
autoFocus = { true }

Check failure on line 138 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

Props should be sorted alphabetically
/>

Check failure on line 139 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

The closing bracket must be placed after the last prop{{details}}

</div>
</div>
)}
Expand All @@ -147,7 +157,9 @@ class ChatInput extends Component<IProps, IState> {
accessibilityLabel = { this.props.t('chat.sendButton') }
disabled = { !this.state.message.trim() }
icon = { IconSend }
onClick = { this._onSubmitMessage }
onClick={() => {

Check failure on line 160 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

JSX props should not use arrow functions

Check failure on line 160 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

A space is required before '='

Check failure on line 160 in react/features/chat/components/web/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Lint

A space is required after '='
this._onSubmitMessage()
this._toggleSmileysPanel();}}
size = { isMobileBrowser() ? 'large' : 'medium' } />
</div>
</div>
Expand Down Expand Up @@ -260,6 +272,13 @@ class ChatInput extends Component<IProps, IState> {
}
this.setState({ showSmileysPanel: !this.state.showSmileysPanel });
}


addEmoji = e => {
const emoji = e.native;

this.setState({ message: this.state.message + emoji });
};
}

/**
Expand All @@ -280,4 +299,4 @@ const mapStateToProps = (state: IReduxState) => {
};
};

export default translate(connect(mapStateToProps)(ChatInput));
export default translate(connect(mapStateToProps)(ChatInput));

0 comments on commit 9f7f3cf

Please sign in to comment.