allow message input textarea height to grow with more text

This commit is contained in:
or-else
2023-03-14 13:53:21 -07:00
parent 43798ea1d9
commit 5ae58fb2a6
7 changed files with 20 additions and 7 deletions
+8 -1
View File
@@ -197,7 +197,7 @@ textarea {
height: 2.5rem; height: 2.5rem;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
transition: all 0.1s ease-in-out; transition: all 0.1s ease-in-out, height 0s;
} }
input[type="text"], input[type="text"],
@@ -1508,6 +1508,13 @@ img.channel {
color: #2196f3!important; color: #2196f3!important;
} }
/* The textarea where the message is entered. */
#send-message-input {
overflow: hidden auto;
min-height: 2.5rem;
max-height: 6rem;
}
/* New chat invitation panel */ /* New chat invitation panel */
.accept-invite-panel { .accept-invite-panel {
+1 -1
View File
File diff suppressed because one or more lines are too long
+5 -1
View File
@@ -111,6 +111,10 @@ class SendMessage extends React.PureComponent {
// Set focus on desktop, but not on mobile: focus causes soft keyboard to pop up. // Set focus on desktop, but not on mobile: focus causes soft keyboard to pop up.
this.messageEditArea.focus(); this.messageEditArea.focus();
} }
// Adjust height of the message area for the amount of text.
this.messageEditArea.style.height = '0px';
this.messageEditArea.style.height = this.messageEditArea.scrollHeight + 'px';
} }
if (prevProps.topicName != this.props.topicName) { if (prevProps.topicName != this.props.topicName) {
@@ -276,7 +280,7 @@ class SendMessage extends React.PureComponent {
</Suspense>) : </Suspense>) :
<textarea id="send-message-input" placeholder={prompt} <textarea id="send-message-input" placeholder={prompt}
value={this.state.message} onChange={this.handleMessageTyping} value={this.state.message} onChange={this.handleMessageTyping}
onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyPress}
ref={ref => {this.messageEditArea = ref;}} />)} ref={ref => {this.messageEditArea = ref;}} />)}
{this.state.message || !audioEnabled ? {this.state.message || !audioEnabled ?
<a href="#" onClick={this.handleSend} title={formatMessage(messages.icon_title_send)}> <a href="#" onClick={this.handleSend} title={formatMessage(messages.icon_title_send)}>
+3 -1
View File
@@ -14981,6 +14981,8 @@ class SendMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
if (window.getComputedStyle(this.messageEditArea).getPropertyValue('transition-property') == 'all') { if (window.getComputedStyle(this.messageEditArea).getPropertyValue('transition-property') == 'all') {
this.messageEditArea.focus(); this.messageEditArea.focus();
} }
this.messageEditArea.style.height = '0px';
this.messageEditArea.style.height = this.messageEditArea.scrollHeight + 'px';
} }
if (prevProps.topicName != this.props.topicName) { if (prevProps.topicName != this.props.topicName) {
this.setState({ this.setState({
@@ -15151,7 +15153,7 @@ class SendMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
placeholder: prompt, placeholder: prompt,
value: this.state.message, value: this.state.message,
onChange: this.handleMessageTyping, onChange: this.handleMessageTyping,
onKeyPress: this.handleKeyPress, onKeyDown: this.handleKeyPress,
ref: ref => { ref: ref => {
this.messageEditArea = ref; this.messageEditArea = ref;
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long