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