fix(components): [el-date-picker] panel position error after view switch (#5277)

* fix(components): [el-date-picker] panel position error after view switch

* fix: [el-popper] zIndex not update issue
This commit is contained in:
msidolphin 2022-01-11 10:40:40 +08:00 committed by GitHub
parent 57e0d1d1bb
commit 82182a91aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View File

@ -182,6 +182,7 @@ import {
DArrowRight,
ArrowRight,
} from '@element-plus/icons-vue'
import { TOOLTIP_INJECTION_KEY } from '@element-plus/components/tooltip'
import DateTable from './basic-date-table.vue'
import MonthTable from './basic-month-table.vue'
import YearTable from './basic-year-table.vue'
@ -232,7 +233,7 @@ export default defineComponent({
setup(props, ctx) {
const { t, lang } = useLocale()
const pickerBase = inject('EP_PICKER_BASE') as any
const popper = inject(TOOLTIP_INJECTION_KEY)
const {
shortcuts,
disabledDate,
@ -385,6 +386,13 @@ export default defineComponent({
{ immediate: true }
)
watch(
() => currentView.value,
() => {
popper?.updatePopper()
}
)
const hasShortcuts = computed(() => !!shortcuts.length)
const handleMonthPick = (month) => {

View File

@ -44,9 +44,7 @@ export default defineComponent({
arrowRef,
arrowOffset,
})
const contentZIndex = computed(
() => props.zIndex || PopupManager.nextZIndex()
)
const contentZIndex = ref(props.zIndex || PopupManager.nextZIndex())
const contentStyle = computed(
() => [{ zIndex: unref(contentZIndex) }, props.popperStyle] as any
@ -76,6 +74,7 @@ export default defineComponent({
const updatePopper = () => {
unref(popperInstanceRef)?.update()
contentZIndex.value = props.zIndex || PopupManager.nextZIndex()
}
onMounted(() => {

View File

@ -3,4 +3,5 @@ import Tooltip from './src/tooltip.vue'
export const ElTooltip = withInstall(Tooltip)
export * from './src/tooltip'
export * from './src/tokens'
export default ElTooltip

View File

@ -11,6 +11,7 @@ export type ElTooltipInjectionContext = {
onToggle: (e: Event) => void
onShow: () => void
onHide: () => void
updatePopper: () => void
}
export const TOOLTIP_INJECTION_KEY: InjectionKey<ElTooltipInjectionContext> =

View File

@ -159,6 +159,7 @@ export default defineComponent({
onHide: () => {
emit('hide')
},
updatePopper,
})
return {