Skip to content

Commit 46addfb

Browse files
committed
✨ Refactor Chat Widget and Remove Unused Features ✨
- 🗑️ Removed the 'text_area_wrap' field from the widget theme configuration as it was no longer needed. - 🎨 Updated the widget theme template to remove the associated input field for 'text_area_wrap'. - 🔄 Adjusted the user chat layout to ensure compatibility with the new widget structure. - 📦 Updated React components to handle textarea resizing dynamically, improving user experience. - 🔧 Cleaned up the StartChat component by removing unnecessary calculations related to 'text_area_wrap'. - 🔄 Updated API responses to eliminate references to 'text_area_wrap', ensuring consistency across the application. - 📈 Bumped the React app version to 389 to reflect the latest changes. These changes streamline the chat widget functionality and enhance the overall performance of the application. 🚀
1 parent ee8ff3f commit 46addfb

File tree

15 files changed

+44
-47
lines changed

15 files changed

+44
-47
lines changed

lhc_web/design/defaulttheme/css/css_static/2e09162829e15b6cbc70195cf8bb6b29.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lhc_web/design/defaulttheme/css/css_static/6cc8571e0e95098f55b7de6f9713354a.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lhc_web/design/defaulttheme/css/css_static/91b0a7056b7f8428a91be2f55972b537.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lhc_web/design/defaulttheme/css/widgetv2/widget.css

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ div.message-row {
128128
scrollbar-width: thin;
129129
}
130130

131+
132+
133+
131134
.header-chat {
132135
background-color: #ededed;
133136
user-select: none;
@@ -902,6 +905,8 @@ textarea[name=ChatMessage] {
902905
scrollbar-color: #888 transparent;
903906
scrollbar-width: thin;
904907
scroll-padding-bottom: 10px;
908+
max-height: 100px ; /* Limit to ~4 lines */
909+
field-sizing: content;
905910
}
906911

907912
.settings {
@@ -1226,15 +1231,6 @@ a.btn-link.visited{
12261231
margin-left:0!important;
12271232
}
12281233

1229-
#CSChatMessage.msg-two-line{
1230-
height:56px;
1231-
}
1232-
1233-
#CSChatMessage.msg-one-line{
1234-
height:36px;
1235-
overflow-y: hidden;
1236-
}
1237-
12381234
.bb-list > a.p-1{
12391235
padding:1px !important;
12401236
}

lhc_web/design/defaulttheme/js/widgetv2/react.app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lhc_web/design/defaulttheme/js/widgetv2/react.app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lhc_web/design/defaulttheme/tpl/lhabstract/custom/widget_theme.tpl.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,6 @@
420420
<?php echo erLhcoreClassAbstract::renderInput('widget_border_width', $fields['widget_border_width'], $object)?>
421421
</div>
422422
</div>
423-
<div class="col-6">
424-
<div class="form-group">
425-
<label><?php echo $fields['text_area_wrap']['trans'];?></label>
426-
<?php echo erLhcoreClassAbstract::renderInput('text_area_wrap', $fields['text_area_wrap'], $object)?>
427-
</div>
428-
</div>
429423
</div>
430424

431425
<div class="row">

lhc_web/design/defaulttheme/tpl/pagelayouts/userchat2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@
102102
) : ?>
103103
<?php if (!isset($Result['voice_call'])) : ?>
104104
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/vendor.ie.js')?>?v=a4"></script>
105-
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.ie.js')?>?t=387"></script>
105+
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.ie.js')?>?t=388"></script>
106106
<?php else : ?>
107107
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/voice/voice.call.js')?>?t=3"></script>
108108
<?php endif; ?>
109109
<?php else : ?>
110110
<?php if (!isset($Result['voice_call'])) : ?>
111111
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/vendor.js')?>?v=a4"></script>
112-
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.js')?>?t=387"></script>
112+
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.js')?>?t=388"></script>
113113
<?php else : ?>
114114
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/voice/voice.call.js')?>?t=2"></script>
115115
<?php endif; ?>

lhc_web/design/defaulttheme/widget/react-app/src/components/OnlineChat.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class OnlineChat extends Component {
9696
this.changeLanguage = this.changeLanguage.bind(this);
9797
this.onFilePreview = this.onFilePreview.bind(this);
9898
this.removeFilePreview = this.removeFilePreview.bind(this);
99+
this.onTextareaResize = this.onTextareaResize.bind(this);
99100

100101
// Messages Area
101102
this.messagesAreaRef = React.createRef();
@@ -976,6 +977,15 @@ class OnlineChat extends Component {
976977
});
977978
}
978979

980+
onTextareaResize() {
981+
if (this.messagesAreaRef.current) {
982+
let scrollValue = this.messagesAreaRef.current.scrollHeight - this.messagesAreaRef.current.scrollTop;
983+
if ((scrollValue - this.messagesAreaRef.current.offsetHeight) < 70) {
984+
this.scrollBottom(false, false);
985+
}
986+
}
987+
}
988+
979989
render() {
980990
const { t } = this.props;
981991

@@ -1121,8 +1131,6 @@ class OnlineChat extends Component {
11211131

11221132
const fontSizeStyle = {fontSize: (this.props.chatwidget.hasIn(['chat_ui','font_size']) ? this.state.fontSize : '100') + '%'};
11231133

1124-
const taw = this.props.chatwidget.hasIn(['chat_ui','taw']) ? this.props.chatwidget.getIn(['chat_ui','taw']) : 8.6;
1125-
11261134
return (
11271135
<React.Fragment>
11281136

@@ -1230,9 +1238,10 @@ class OnlineChat extends Component {
12301238
onTextKeyDown={this.enterKeyDown}
12311239
textReadOnly={this.props.chatwidget.getIn(['chatLiveData','closed']) || this.props.chatwidget.get('network_down')}
12321240
onTextFocus={(e) => {this.setState({'reactToMsgId' : 0})}}
1233-
classNameText={"ps-0 no-outline form-control rounded-0 form-control rounded-start-0 rounded-end-0 border-0 "+((this.props.chatwidget.get('shown') === true && this.textMessageRef.current && (/\r|\n/.exec(this.state.value) || (this.state.value.length > this.textMessageRef.current.offsetWidth/taw))) ? 'msg-two-line' : 'msg-one-line')}
1241+
classNameText={"ps-0 no-outline form-control rounded-0 form-control rounded-start-0 rounded-end-0 border-0"}
12341242
textPlaceholder={placeholder}
12351243
textareaRef={this.props.textMessageRef}
1244+
onResize={this.onTextareaResize}
12361245
/>
12371246
</React.Fragment>
12381247
}

lhc_web/design/defaulttheme/widget/react-app/src/components/SharedTextarea.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import React from 'react';
22

33
class SharedTextarea extends React.Component {
4+
componentDidMount() {
5+
const el = this.props.textareaRef && this.props.textareaRef.current;
6+
if (!el) return;
7+
this._resizeObserver = new ResizeObserver(() => {
8+
if (typeof this.props.onResize === 'function') {
9+
this.props.onResize();
10+
}
11+
});
12+
this._resizeObserver.observe(el);
13+
}
14+
15+
componentWillUnmount() {
16+
if (this._resizeObserver) {
17+
this._resizeObserver.disconnect();
18+
this._resizeObserver = null;
19+
}
20+
}
21+
422
render() {
523
const {text, onTextChange, textareaRef, classNameText, textPlaceholder, onTextKeyDown, onTextFocus, textAutoFocus, textMaxLength, onTextTouchStart, onTextKeyUp, textReadOnly} = this.props;
624

0 commit comments

Comments
 (0)