Skip to content

Commit

Permalink
Merge pull request zhandouxiaojiji#11 from 91Act/pull_request1
Browse files Browse the repository at this point in the history
 fix: 编辑时节点参数时,鼠标按下并选中内容后,如果鼠标弹起时位于G6树状图区域,节点的选中状态会被取消。
  • Loading branch information
zhandouxiaojiji authored Sep 17, 2022
2 parents 50e42bd + b9a995d commit 1df5042
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions render-process/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface EditorProps {

interface EditorState {
curNodeId?: string;
blockNodeSelectChange?: boolean;
}

export default class Editor extends React.Component<EditorProps, EditorState> {
Expand Down Expand Up @@ -113,7 +114,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
},
},
});

graph.on("contextmenu", (e: G6GraphEvent) => {
require("@electron/remote").Menu.getApplicationMenu().popup();
});
Expand All @@ -135,6 +136,11 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
});

graph.on("nodeselectchange", (e: G6GraphEvent) => {
if (this.state.blockNodeSelectChange) {
// ** 重置选中效果
this.onSelectNode(this.state.curNodeId)
return;
}
if (e.target) {
this.onSelectNode(e.target.getID());
} else {
Expand Down Expand Up @@ -481,8 +487,12 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
return (
<div className="editor">
<Row className="editorBd">
<Col span={18} className="editorContent" ref={this.ref} />
<Col span={6} className="editorSidebar">
<Col span={18} className="editorContent" ref={this.ref} onMouseDownCapture={(event) => {
this.state.blockNodeSelectChange = false;
}} />
<Col span={6} className="editorSidebar" onMouseDownCapture={(event) => {
this.state.blockNodeSelectChange = true;
}}>
{curNode ? (
<NodePanel
model={curNode}
Expand All @@ -504,19 +514,19 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
}}
/>
) : (
<TreePanel
model={this.treeModel}
onRenameTree={(name: string) => {

}}
onRemoveTree={() => {

}}
onChangeTreeDesc={(desc) => {
this.changeTreeDesc(desc);
}}
/>
)}
<TreePanel
model={this.treeModel}
onRenameTree={(name: string) => {

}}
onRemoveTree={() => {

}}
onChangeTreeDesc={(desc) => {
this.changeTreeDesc(desc);
}}
/>
)}
</Col>
</Row>
</div>
Expand Down

0 comments on commit 1df5042

Please sign in to comment.