mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
fix(components): [table] failed to insert tooltip when show-overflow-tooltip is enabled (#18317)
* fix:The namespace of the showOverflowTooltip is invalid. * fix(components): [scrollbar] multiple rendering * fix(components): [scrollbar] multiple rendering * fix(components): [scrollbar] multiple rendering * Update packages/components/scrollbar/src/bar.vue Co-authored-by: kooriookami <38392315+kooriookami@users.noreply.github.com> * test(components): [scrollbar] adjusting style attributes * fix(components): [table] Failed to insert node when show-overflow-tooltip is enabled * fix(components): [table] Failed to insert node when show-overflow-tooltip is enabled * fix(components): [table] Failed to insert node when show-overflow-tooltip is enabled * fix(components): [table] Failed to insert node when show-overflow-tooltip is enabled --------- Co-authored-by: kooriookami <38392315+kooriookami@users.noreply.github.com>
This commit is contained in:
parent
c0f071e464
commit
ffb30818cf
@ -1,6 +1,6 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { createVNode, render } from 'vue'
|
import { createVNode, render } from 'vue'
|
||||||
import { flatMap, get } from 'lodash-unified'
|
import { flatMap, get, merge } from 'lodash-unified'
|
||||||
import {
|
import {
|
||||||
hasOwn,
|
hasOwn,
|
||||||
isArray,
|
isArray,
|
||||||
@ -16,6 +16,7 @@ import ElTooltip, {
|
|||||||
} from '@element-plus/components/tooltip'
|
} from '@element-plus/components/tooltip'
|
||||||
import type { Table, TreeProps } from './table/defaults'
|
import type { Table, TreeProps } from './table/defaults'
|
||||||
import type { TableColumnCtx } from './table-column/defaults'
|
import type { TableColumnCtx } from './table-column/defaults'
|
||||||
|
import type { VNode } from 'vue'
|
||||||
|
|
||||||
export type TableOverflowTooltipOptions = Partial<
|
export type TableOverflowTooltipOptions = Partial<
|
||||||
Pick<
|
Pick<
|
||||||
@ -36,6 +37,7 @@ export type TableOverflowTooltipOptions = Partial<
|
|||||||
|
|
||||||
type RemovePopperFn = (() => void) & {
|
type RemovePopperFn = (() => void) & {
|
||||||
trigger?: HTMLElement
|
trigger?: HTMLElement
|
||||||
|
vm?: VNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCell = function (event: Event) {
|
export const getCell = function (event: Event) {
|
||||||
@ -363,6 +365,20 @@ export function walkTreeNode(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getTableOverflowTooltipProps = (
|
||||||
|
props: TableOverflowTooltipOptions,
|
||||||
|
content: string
|
||||||
|
) => {
|
||||||
|
return {
|
||||||
|
content,
|
||||||
|
...props,
|
||||||
|
popperOptions: {
|
||||||
|
strategy: 'fixed',
|
||||||
|
...props.popperOptions,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export let removePopper: RemovePopperFn | null = null
|
export let removePopper: RemovePopperFn | null = null
|
||||||
|
|
||||||
export function createTablePopper(
|
export function createTablePopper(
|
||||||
@ -372,17 +388,16 @@ export function createTablePopper(
|
|||||||
table: Table<[]>
|
table: Table<[]>
|
||||||
) {
|
) {
|
||||||
if (removePopper?.trigger === trigger) {
|
if (removePopper?.trigger === trigger) {
|
||||||
|
merge(
|
||||||
|
removePopper!.vm.component.props,
|
||||||
|
getTableOverflowTooltipProps(props, popperContent)
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
removePopper?.()
|
removePopper?.()
|
||||||
const parentNode = table?.refs.tableWrapper
|
const parentNode = table?.refs.tableWrapper
|
||||||
const ns = parentNode?.dataset.prefix
|
const ns = parentNode?.dataset.prefix
|
||||||
const popperOptions = {
|
|
||||||
strategy: 'fixed',
|
|
||||||
...props.popperOptions,
|
|
||||||
}
|
|
||||||
const vm = createVNode(ElTooltip, {
|
const vm = createVNode(ElTooltip, {
|
||||||
content: popperContent,
|
|
||||||
virtualTriggering: true,
|
virtualTriggering: true,
|
||||||
virtualRef: trigger,
|
virtualRef: trigger,
|
||||||
appendTo: parentNode,
|
appendTo: parentNode,
|
||||||
@ -390,11 +405,7 @@ export function createTablePopper(
|
|||||||
transition: 'none', // Default does not require transition
|
transition: 'none', // Default does not require transition
|
||||||
offset: 0,
|
offset: 0,
|
||||||
hideAfter: 0,
|
hideAfter: 0,
|
||||||
...props,
|
...getTableOverflowTooltipProps(props, popperContent),
|
||||||
popperOptions,
|
|
||||||
onHide: () => {
|
|
||||||
removePopper?.()
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
vm.appContext = { ...table.appContext, ...table }
|
vm.appContext = { ...table.appContext, ...table }
|
||||||
const container = document.createElement('div')
|
const container = document.createElement('div')
|
||||||
@ -407,6 +418,7 @@ export function createTablePopper(
|
|||||||
removePopper = null
|
removePopper = null
|
||||||
}
|
}
|
||||||
removePopper.trigger = trigger
|
removePopper.trigger = trigger
|
||||||
|
removePopper.vm = vm
|
||||||
scrollContainer?.addEventListener('scroll', removePopper)
|
scrollContainer?.addEventListener('scroll', removePopper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user