mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Fix regression where click event in the DOM is no longer being captured (#675)
This commit is contained in:
parent
29ad232ac6
commit
7888a61766
@ -223,32 +223,21 @@ class ChatSidebar extends React.Component<{}, {}> {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (this.sidebarRef.current) {
|
if (this.sidebarRef.current) {
|
||||||
this.sidebarRef.current.addEventListener("click", this.handleSidebarClick);
|
this.sidebarRef.current.addEventListener("click", this.onSidebarClick);
|
||||||
}
|
}
|
||||||
document.addEventListener("click", this.handleClickOutside);
|
|
||||||
this.requestChatUpdate();
|
this.requestChatUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (this.sidebarRef.current) {
|
if (this.sidebarRef.current) {
|
||||||
this.sidebarRef.current.removeEventListener("click", this.handleSidebarClick);
|
this.sidebarRef.current.removeEventListener("click", this.onSidebarClick);
|
||||||
}
|
}
|
||||||
document.removeEventListener("click", this.handleClickOutside);
|
|
||||||
GlobalModel.sidebarchatModel.resetFocus();
|
GlobalModel.sidebarchatModel.resetFocus();
|
||||||
if (this.disposeReaction) {
|
if (this.disposeReaction) {
|
||||||
this.disposeReaction();
|
this.disposeReaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@mobx.action.bound
|
|
||||||
handleClickOutside(e: MouseEvent) {
|
|
||||||
const sidebar = this.sidebarRef.current;
|
|
||||||
if (sidebar && !sidebar.contains(e.target as Node)) {
|
|
||||||
GlobalModel.sidebarchatModel.resetFocus();
|
|
||||||
GlobalModel.inputModel.giveFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
requestChatUpdate() {
|
requestChatUpdate() {
|
||||||
const chatMessageItems = GlobalModel.inputModel.AICmdInfoChatItems.slice();
|
const chatMessageItems = GlobalModel.inputModel.AICmdInfoChatItems.slice();
|
||||||
if (chatMessageItems == null || chatMessageItems.length === 0) {
|
if (chatMessageItems == null || chatMessageItems.length === 0) {
|
||||||
@ -326,6 +315,11 @@ class ChatSidebar extends React.Component<{}, {}> {
|
|||||||
currentRef.setRangeText("\n", currentRef.selectionStart, currentRef.selectionEnd, "end");
|
currentRef.setRangeText("\n", currentRef.selectionStart, currentRef.selectionEnd, "end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mobx.action.bound
|
||||||
|
onBlur() {
|
||||||
|
GlobalModel.sidebarchatModel.resetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
updatePreTagOutline(clickedPre?) {
|
updatePreTagOutline(clickedPre?) {
|
||||||
const pres = this.chatWindowRef.current?.querySelectorAll("pre");
|
const pres = this.chatWindowRef.current?.querySelectorAll("pre");
|
||||||
if (pres == null) {
|
if (pres == null) {
|
||||||
@ -342,7 +336,7 @@ class ChatSidebar extends React.Component<{}, {}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@mobx.action.bound
|
@mobx.action.bound
|
||||||
handleSidebarClick(event) {
|
onSidebarClick(event) {
|
||||||
const target = event.target as HTMLElement;
|
const target = event.target as HTMLElement;
|
||||||
if (
|
if (
|
||||||
target.closest(".copy-button") ||
|
target.closest(".copy-button") ||
|
||||||
@ -547,6 +541,7 @@ class ChatSidebar extends React.Component<{}, {}> {
|
|||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
autoCorrect="off"
|
autoCorrect="off"
|
||||||
className="sidebarchat-input chat-textarea"
|
className="sidebarchat-input chat-textarea"
|
||||||
|
onBlur={this.onBlur}
|
||||||
onFocus={this.onTextAreaFocus}
|
onFocus={this.onTextAreaFocus}
|
||||||
onMouseDown={this.onTextAreaMouseDown} // When the user clicks on the textarea
|
onMouseDown={this.onTextAreaMouseDown} // When the user clicks on the textarea
|
||||||
onChange={this.onTextAreaChange}
|
onChange={this.onTextAreaChange}
|
||||||
|
Loading…
Reference in New Issue
Block a user