fix(components): [popper] provide formItemContext conditionally (#7790)

This commit is contained in:
Carter Li 2022-05-20 12:01:19 +08:00 committed by GitHub
parent 488eaf5211
commit 6cc11662a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@
<script lang="ts" setup>
import { computed, inject, onMounted, provide, ref, unref, watch } from 'vue'
import { NOOP } from '@vue/shared'
import { createPopper } from '@popperjs/core'
import { useNamespace, useZIndex } from '@element-plus/hooks'
import {
@ -50,12 +51,18 @@ provide(POPPER_CONTENT_INJECTION_KEY, {
arrowRef,
arrowOffset,
})
// disallow auto-id from inside popper content
provide(formItemContextKey, {
...formItemContext,
addInputId: () => undefined,
removeInputId: () => undefined,
})
if (
formItemContext &&
(formItemContext.addInputId || formItemContext.removeInputId)
) {
// disallow auto-id from inside popper content
provide(formItemContextKey, {
...formItemContext,
addInputId: NOOP,
removeInputId: NOOP,
})
}
const contentZIndex = ref(props.zIndex || nextZIndex())