Commit 9b8f165a365758d001e6d86ae7afe4ae3316d485
1 parent
e1c47233
fix(table-action): stopButtonPropagation not working
修复TableAction组件的stopButtonPropagation属性无效的问题
Showing
2 changed files
with
6 additions
and
4 deletions
CHANGELOG.zh_CN.md
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | - **ApiTreeSelect** 修复未能正确监听`params`变化的问题 | 3 | - **ApiTreeSelect** 修复未能正确监听`params`变化的问题 |
4 | - **BasicTable** 修复可编辑单元格不支持`ellipsis`配置的问题 | 4 | - **BasicTable** 修复可编辑单元格不支持`ellipsis`配置的问题 |
5 | - **ImgRotateDragVerify** 修复组件`resume`方法无法调用的问题 | 5 | - **ImgRotateDragVerify** 修复组件`resume`方法无法调用的问题 |
6 | +- **TableAction** 修复 stopButtonPropagation 属性某些情况下不起作用的问题 | ||
6 | - **Dark Theme** 黑暗主题下的配色问题修正 | 7 | - **Dark Theme** 黑暗主题下的配色问题修正 |
7 | - 修复`Tree`组件被选中节点的背景颜色 | 8 | - 修复`Tree`组件被选中节点的背景颜色 |
8 | - 修复`Alert`组件的颜色配置 | 9 | - 修复`Alert`组件的颜色配置 |
src/components/Table/src/components/TableAction.vue
@@ -140,10 +140,11 @@ | @@ -140,10 +140,11 @@ | ||
140 | 140 | ||
141 | function onCellClick(e: MouseEvent) { | 141 | function onCellClick(e: MouseEvent) { |
142 | if (!props.stopButtonPropagation) return; | 142 | if (!props.stopButtonPropagation) return; |
143 | - const target = e.target as HTMLElement; | ||
144 | - if (target.tagName === 'BUTTON') { | ||
145 | - e.stopPropagation(); | ||
146 | - } | 143 | + const path = e.composedPath() as HTMLElement[]; |
144 | + const isInButton = path.find((ele) => { | ||
145 | + return ele.tagName?.toUpperCase() === 'BUTTON'; | ||
146 | + }); | ||
147 | + isInButton && e.stopPropagation(); | ||
147 | } | 148 | } |
148 | 149 | ||
149 | return { prefixCls, getActions, getDropdownList, getAlign, onCellClick, getTooltip }; | 150 | return { prefixCls, getActions, getDropdownList, getAlign, onCellClick, getTooltip }; |