Skip to content

Commit acf3b79

Browse files
committed
fix(libro-view): 修复编辑器焦点逻辑判断问题,避免 Notebook 虽然失焦但 focus 没被清掉导致快捷键仍然处于启用状态
1 parent ec4bcc0 commit acf3b79

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

packages/libro-core/src/libro-view.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,16 @@ export const LibroRender = forwardRef<HTMLDivElement>(function LibroRender(props
262262
if (typeof ref === 'function') {
263263
return;
264264
}
265-
// focus编辑器host
266-
if (!e.relatedTarget) {
267-
return;
268-
}
269-
// focus编辑器外部区域
270-
if (ref?.current?.contains(e.relatedTarget)) {
265+
const target = e.relatedTarget as Node | null;
266+
const inside = target ? ref?.current?.contains(target) : false;
267+
268+
if (inside) {
271269
const dndDom = ref?.current?.getElementsByClassName(
272270
'libro-dnd-cells-container',
273271
)[0];
274272

275273
if (
276-
!dndDom?.contains(e.relatedTarget) &&
274+
!dndDom?.contains(target as Node) &&
277275
(!instance.model.inputEditable ||
278276
!instance.model.outputEditable ||
279277
!instance.model.cellsEditable) &&

0 commit comments

Comments
 (0)