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) {
|
||||
this.sidebarRef.current.addEventListener("click", this.handleSidebarClick);
|
||||
this.sidebarRef.current.addEventListener("click", this.onSidebarClick);
|
||||
}
|
||||
document.addEventListener("click", this.handleClickOutside);
|
||||
this.requestChatUpdate();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
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();
|
||||
if (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() {
|
||||
const chatMessageItems = GlobalModel.inputModel.AICmdInfoChatItems.slice();
|
||||
if (chatMessageItems == null || chatMessageItems.length === 0) {
|
||||
@ -326,6 +315,11 @@ class ChatSidebar extends React.Component<{}, {}> {
|
||||
currentRef.setRangeText("\n", currentRef.selectionStart, currentRef.selectionEnd, "end");
|
||||
}
|
||||
|
||||
@mobx.action.bound
|
||||
onBlur() {
|
||||
GlobalModel.sidebarchatModel.resetFocus();
|
||||
}
|
||||
|
||||
updatePreTagOutline(clickedPre?) {
|
||||
const pres = this.chatWindowRef.current?.querySelectorAll("pre");
|
||||
if (pres == null) {
|
||||
@ -342,7 +336,7 @@ class ChatSidebar extends React.Component<{}, {}> {
|
||||
}
|
||||
|
||||
@mobx.action.bound
|
||||
handleSidebarClick(event) {
|
||||
onSidebarClick(event) {
|
||||
const target = event.target as HTMLElement;
|
||||
if (
|
||||
target.closest(".copy-button") ||
|
||||
@ -547,6 +541,7 @@ class ChatSidebar extends React.Component<{}, {}> {
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
className="sidebarchat-input chat-textarea"
|
||||
onBlur={this.onBlur}
|
||||
onFocus={this.onTextAreaFocus}
|
||||
onMouseDown={this.onTextAreaMouseDown} // When the user clicks on the textarea
|
||||
onChange={this.onTextAreaChange}
|
||||
|
Loading…
Reference in New Issue
Block a user