Skip to content

Commit

Permalink
fix: 修复 dropdown 事件穿透问题
Browse files Browse the repository at this point in the history
  • Loading branch information
winixt committed Jun 17, 2023
1 parent 08273d0 commit df65ea1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export default defineComponent({
const hasIcon = computed(() =>
props.options.some((option) => option.icon),
);
const handleClick = (option: Option) => {
const handleClick = (option: Option, event: Event) => {
event.preventDefault();
event.stopPropagation();
if (option.disabled) return;
const value = option[props.valueField] as Option['value'];
currentValue.value = value;
Expand Down Expand Up @@ -126,8 +128,8 @@ export default defineComponent({
return (
<div
class={optionClassList}
onClick={() => {
handleClick(option);
onClick={(event: Event) => {
handleClick(option, event);
}}
>
{option.icon && (
Expand Down

0 comments on commit df65ea1

Please sign in to comment.