mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-27 02:01:15 +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
|
||||
import { createVNode, render } from 'vue'
|
||||
import { flatMap, get } from 'lodash-unified'
|
||||
import { flatMap, get, merge } from 'lodash-unified'
|
||||
import {
|
||||
hasOwn,
|
||||
isArray,
|
||||
@ -16,6 +16,7 @@ import ElTooltip, {
|
||||
} from '@element-plus/components/tooltip'
|
||||
import type { Table, TreeProps } from './table/defaults'
|
||||
import type { TableColumnCtx } from './table-column/defaults'
|
||||
import type { VNode } from 'vue'
|
||||
|
||||
export type TableOverflowTooltipOptions = Partial<
|
||||
Pick<
|
||||
@ -36,6 +37,7 @@ export type TableOverflowTooltipOptions = Partial<
|
||||
|
||||
type RemovePopperFn = (() => void) & {
|
||||
trigger?: HTMLElement
|
||||
vm?: VNode
|
||||
}
|
||||
|
||||
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 function createTablePopper(
|
||||
@ -372,17 +388,16 @@ export function createTablePopper(
|
||||
table: Table<[]>
|
||||
) {
|
||||
if (removePopper?.trigger === trigger) {
|
||||
merge(
|
||||
removePopper!.vm.component.props,
|
||||
getTableOverflowTooltipProps(props, popperContent)
|
||||
)
|
||||
return
|
||||
}
|
||||
removePopper?.()
|
||||
const parentNode = table?.refs.tableWrapper
|
||||
const ns = parentNode?.dataset.prefix
|
||||
const popperOptions = {
|
||||
strategy: 'fixed',
|
||||
...props.popperOptions,
|
||||
}
|
||||
const vm = createVNode(ElTooltip, {
|
||||
content: popperContent,
|
||||
virtualTriggering: true,
|
||||
virtualRef: trigger,
|
||||
appendTo: parentNode,
|
||||
@ -390,11 +405,7 @@ export function createTablePopper(
|
||||
transition: 'none', // Default does not require transition
|
||||
offset: 0,
|
||||
hideAfter: 0,
|
||||
...props,
|
||||
popperOptions,
|
||||
onHide: () => {
|
||||
removePopper?.()
|
||||
},
|
||||
...getTableOverflowTooltipProps(props, popperContent),
|
||||
})
|
||||
vm.appContext = { ...table.appContext, ...table }
|
||||
const container = document.createElement('div')
|
||||
@ -407,6 +418,7 @@ export function createTablePopper(
|
||||
removePopper = null
|
||||
}
|
||||
removePopper.trigger = trigger
|
||||
removePopper.vm = vm
|
||||
scrollContainer?.addEventListener('scroll', removePopper)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user