Skip to content

Commit

Permalink
fix(treeselect): prevent trigger onBlur when click folder icon
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Jan 30, 2023
1 parent ece3013 commit c4b46aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/tree/hooks/useItemEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export default function useItemEvents(props: TypeTreeItemProps, context: SetupCo
};

let clicked = false;

const handleMousedown = (evt: MouseEvent) => {
// 在mousedown阶段阻止冒泡 应用于处理如展开阻止下拉框失焦等场景
// evt.preventDefault();
};

const handleClick = (evt: MouseEvent) => {
const { expandOnClickNode } = props;
const srcTarget = evt.target as HTMLElement;
Expand Down Expand Up @@ -50,5 +56,6 @@ export default function useItemEvents(props: TypeTreeItemProps, context: SetupCo
return {
handleChange,
handleClick,
handleMousedown,
};
}
3 changes: 2 additions & 1 deletion src/tree/hooks/useTreeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function useTreeItem(props: TypeTreeItemProps, context: SetupCont
const classPrefix = usePrefixClass().value;
const componentName = usePrefixClass('tree').value;

const { handleClick } = useItemEvents(props, context);
const { handleClick, handleMousedown } = useItemEvents(props, context);
const { renderIcon } = useRenderIcon(props);
const { renderLabel } = useRenderLabel(props, context);
const { renderLine } = useRenderLine(props);
Expand Down Expand Up @@ -107,6 +107,7 @@ export default function useTreeItem(props: TypeTreeItemProps, context: SetupCont
data-value={value}
data-level={level}
style={styles}
onMousedown={handleMousedown}
onClick={(evt: MouseEvent) => handleClick(evt)}
draggable={node.isDraggable()}
onDragstart={(evt: DragEvent) => handleDragStart(evt)}
Expand Down

0 comments on commit c4b46aa

Please sign in to comment.