Skip to content

Commit 2bda6f7

Browse files
committed
fix(core): 修复边选中偶发失焦问题
1 parent 904f799 commit 2bda6f7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/core/src/view/edge/BaseEdge.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createElement as h, Component, createRef } from 'preact/compat'
2+
import { isFunction, isNil } from 'lodash-es'
23
import { Circle } from '../shape'
34
import { LineText } from '../text'
45
import LogicFlow from '../../LogicFlow'
@@ -565,6 +566,15 @@ export abstract class BaseEdge<P extends IProps> extends Component<
565566
e,
566567
position,
567568
})
569+
// 复制粘贴后会出现点击边时,边会失去焦点的问题,这里手动让边获焦以解决这个问题
570+
const el = e.currentTarget as HTMLElement
571+
const rAF =
572+
!isNil(window) && isFunction(window.requestAnimationFrame)
573+
? window.requestAnimationFrame.bind(window)
574+
: (fn: () => void) => setTimeout(fn, 0)
575+
rAF(() => {
576+
el.focus()
577+
})
568578
}
569579
const { editConfigModel } = graphModel
570580
graphModel.selectEdgeById(model.id, isMultipleSelect(e, editConfigModel))

0 commit comments

Comments
 (0)