Skip to content

Commit

Permalink
fix: 修复静默状态下点击节点和边会修修改节点和边的层级 fix 1588
Browse files Browse the repository at this point in the history
  • Loading branch information
DymoneLewis committed Dec 11, 2024
1 parent 4d0a617 commit 4c5b066
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/view/edge/BaseEdge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export abstract class BaseEdge<P extends IProps> extends Component<
clearTimeout(this.clickTimer)
}
const { model, graphModel } = this.props
const { editConfigModel } = graphModel
const position = graphModel.getPointByClient({
x: ev.clientX,
y: ev.clientY,
Expand All @@ -367,7 +368,10 @@ export abstract class BaseEdge<P extends IProps> extends Component<
ElementState.SHOW_MENU,
position.domOverlayPosition,
)
this.toFront()
// 静默模式下点击节点不变更节点层级
if (!editConfigModel.isSilentMode) {
this.toFront()
}
if (!model.isSelected) {
graphModel.selectEdgeById(model.id)
}
Expand Down Expand Up @@ -456,7 +460,10 @@ export abstract class BaseEdge<P extends IProps> extends Component<
}
const { editConfigModel } = graphModel
graphModel.selectEdgeById(model.id, isMultipleSelect(e, editConfigModel))
this.toFront()
// 静默模式下点击节点不变更节点层级
if (!editConfigModel.isSilentMode) {
this.toFront()
}
}

handleFocus = () => {
Expand Down
11 changes: 9 additions & 2 deletions packages/core/src/view/node/BaseNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
} else {
graphModel.selectNodeById(model.id, isMultiple)
eventOptions.isSelected = true
this.toFront()
// 静默模式下点击节点不变更节点层级
if (!editConfigModel.isSilentMode) {
this.toFront()
}
}

// 不是双击的,默认都是单击
Expand All @@ -392,6 +395,7 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
handleContextMenu = (ev: MouseEvent) => {
ev.preventDefault()
const { model, graphModel } = this.props
const { editConfigModel } = graphModel
// 节点数据,多为事件对象数据抛出
const nodeData = model.getData()

Expand All @@ -412,7 +416,10 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
e: ev,
position,
})
this.toFront()
// 静默模式下点击节点不变更节点层级
if (!editConfigModel.isSilentMode) {
this.toFront()
}
}

handleMouseDown = (ev: MouseEvent) => {
Expand Down

0 comments on commit 4c5b066

Please sign in to comment.