feat(components): [popconfirm] expose hide function and popperRef (#21681)

* feat(components): [popconfirm] expose hide function and popperRef

* Update docs/en-US/component/popconfirm.md

Co-authored-by: btea <2356281422@qq.com>

* Update docs/en-US/component/popconfirm.md

Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com>

* chore: bump tweak

---------

Co-authored-by: yinshenghao <shenghao.yin@eslink.com>
Co-authored-by: btea <2356281422@qq.com>
Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com>
Co-authored-by: Dsaquel <291874700n@gmail.com>
This commit is contained in:
catanswer
2025-08-12 06:12:49 +08:00
committed by GitHub
parent 24cbd4bdbb
commit ee334a635c
2 changed files with 16 additions and 1 deletions

View File

@ -79,3 +79,10 @@ popconfirm/trigger-event
| ---------------- | ------------------------------------- | -------------------------------------------------------------------------------- |
| reference | HTML element that triggers Popconfirm | — |
| actions ^(2.8.1) | content of the Popconfirm footer | ^[object]`{ confirm: (e: MouseEvent) => void, cancel: (e: MouseEvent) => void }` |
### Exposes
| Name | Description | Type |
| ------------------- | ---------------------------- | ------------------------------------------- |
| popperRef ^(2.11.0) | el-popper component instance | ^[object]`Ref<PopperInstance \| undefined>` |
| hide ^(2.11.0) | hide popconfirm | ^[Function]`() => void` |

View File

@ -52,7 +52,7 @@
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { computed, ref, unref } from 'vue'
import ElButton from '@element-plus/components/button'
import ElIcon from '@element-plus/components/icon'
import ElTooltip from '@element-plus/components/tooltip'
@ -72,6 +72,9 @@ const emit = defineEmits(popconfirmEmits)
const { t } = useLocale()
const ns = useNamespace('popconfirm')
const tooltipRef = ref<TooltipInstance>()
const popperRef = computed(() => {
return unref(tooltipRef)?.popperRef
})
const hidePopper = () => {
tooltipRef.value?.onClose?.()
@ -98,4 +101,9 @@ const finalConfirmButtonText = computed(
const finalCancelButtonText = computed(
() => props.cancelButtonText || t('el.popconfirm.cancelButtonText')
)
defineExpose({
popperRef,
hide: hidePopper,
})
</script>