Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 5498c56

Browse files
committed
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat.Livechat into develop
2 parents 75b2429 + fa5658b commit 5498c56

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

src/components/Composer/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export class Composer extends Component {
6363
}
6464

6565
handleInput = (onChange) => () => {
66+
if (this.state.inputLock) {
67+
return;
68+
}
6669
onChange && onChange(sanitize(this.el.innerText));
6770
}
6871

@@ -147,6 +150,9 @@ export class Composer extends Component {
147150

148151
constructor(props) {
149152
super(props);
153+
this.state = {
154+
inputLock: false,
155+
};
150156
this.value = this.props.value;
151157
this.handleNotifyEmojiSelect = this.handleNotifyEmojiSelect.bind(this);
152158

@@ -228,7 +234,13 @@ export class Composer extends Component {
228234
return 0;
229235
}
230236

237+
handleInputLock(locked) {
238+
this.setState({ inputLock: locked });
239+
return 0;
240+
}
241+
231242
render = ({ pre, post, value, placeholder, onChange, onSubmit, onUpload, className, style }) => (
243+
232244
<div className={createClassName(styles, 'composer', { }, [className])} style={style}>
233245
{pre}
234246
<div
@@ -247,6 +259,17 @@ export class Composer extends Component {
247259
onClick: this.handleClick,
248260
}
249261
)}
262+
263+
onCompositionStart={() => {
264+
this.handleInputLock(true);
265+
}}
266+
267+
onCompositionEnd={() => {
268+
this.handleInputLock(false);
269+
onChange && onChange(this.el.innerText);
270+
}}
271+
272+
250273
className={createClassName(styles, 'composer__input')}
251274
/>
252275
{post}

src/components/Messages/MessageText/emoji.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import shortnameToUnicode from '../../Emoji/shortnameToUnicode';
22

3-
const emojiUnicode = '\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]'; // unicode emoji from https://www.regextester.com/106421
3+
const emojiUnicode = '\u00a9|\u00ae|[\u2000-\u3039]|[\u3100-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]'; // unicode emoji from https://www.regextester.com/106421
44

55
const emojiRanges = [
66
emojiUnicode, // unicode emoji from https://www.regextester.com/106421

src/components/Tooltip/index.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,29 @@ const TooltipContext = createContext();
5555
export class TooltipContainer extends Component {
5656
state = {
5757
tooltip: null,
58+
activeChild: null,
59+
event: null,
60+
placement: null,
5861
}
5962

60-
showTooltip = (event, { content, placement = 'bottom' }) => {
63+
showTooltip = (event, { content, placement = 'bottom', childIndex }) => {
6164
const triggerBounds = event.target.getBoundingClientRect();
62-
this.setState({ tooltip: <Tooltip floating placement={placement} triggerBounds={triggerBounds}>{content}</Tooltip> });
65+
this.setState({ tooltip: <Tooltip floating placement={placement} triggerBounds={triggerBounds}>{content}</Tooltip>, activeChild: childIndex, event, placement, content });
6366
}
6467

6568
hideTooltip = () => {
6669
this.setState({ tooltip: null });
6770
}
6871

72+
UNSAFE_componentWillReceiveProps(props) {
73+
if (this.state.tooltip) {
74+
const activeChildren = props?.children?.props?.children[this.state.activeChild];
75+
if (activeChildren && activeChildren.props.content !== this.state.content) {
76+
this.showTooltip(this.state.event, { content: activeChildren.props.content, placement: this.state.placement, childIndex: this.state.activeChild });
77+
}
78+
}
79+
}
80+
6981
render({ children }) {
7082
return (
7183
<TooltipContext.Provider value={{ ...this.state, showTooltip: this.showTooltip, hideTooltip: this.hideTooltip }}>
@@ -81,11 +93,12 @@ export class TooltipContainer extends Component {
8193

8294
export const TooltipTrigger = ({ children, content, placement }) => (
8395
<TooltipContext.Consumer>
84-
{({ showTooltip, hideTooltip }) => toChildArray(children).map((child) => cloneElement(child, {
85-
onMouseEnter: (event) => showTooltip(event, { content, placement }),
96+
{({ showTooltip, hideTooltip }) => toChildArray(children).map((child, index) => cloneElement(child, {
97+
onMouseEnter: (event) => showTooltip(event, { content, placement, childIndex: index }),
8698
onMouseLeave: (event) => hideTooltip(event),
87-
onFocusCapture: (event) => showTooltip(event, { content, placement }),
99+
onFocusCapture: (event) => showTooltip(event, { content, placement, childIndex: index }),
88100
onBlurCapture: (event) => hideTooltip(event),
101+
content,
89102
}))}
90103
</TooltipContext.Consumer>
91104
);

0 commit comments

Comments
 (0)