Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(chat-input) Autofocus when sending private message (#13400)

Robert Pintilii8565208d30a3
diff --git a/react/features/chat/components/web/ChatInput.tsx b/react/features/chat/components/web/ChatInput.tsx
index 127ad56ebb..10db18de9d 100644
--- a/react/features/chat/components/web/ChatInput.tsx
+++ b/react/features/chat/components/web/ChatInput.tsx
@@ -22,6 +22,11 @@ interface IProps extends WithTranslation {
*/
_areSmileysDisabled: boolean;
+ /**
+ * The id of the message recipient, if any.
+ */
+ _privateMessageRecipientId?: string;
+
/**
* Invoked to send chat messages.
*/
@@ -95,6 +100,17 @@ class ChatInput extends Component<IProps, IState> {
}
}
+ /**
+ * Implements {@code Component#componentDidUpdate}.
+ *
+ * @inheritdoc
+ */
+ componentDidUpdate(prevProps: Readonly<IProps>) {
+ if (prevProps._privateMessageRecipientId !== this.props._privateMessageRecipientId) {
+ this._textArea?.current?.focus();
+ }
+ }
+
/**
* Implements React's {@link Component#render()}.
*
@@ -255,8 +271,11 @@ class ChatInput extends Component<IProps, IState> {
* }}
*/
const mapStateToProps = (state: IReduxState) => {
+ const { privateMessageRecipient } = state['features/chat'];
+
return {
- _areSmileysDisabled: areSmileysDisabled(state)
+ _areSmileysDisabled: areSmileysDisabled(state),
+ _privateMessageRecipientId: privateMessageRecipient?.id
};
};