fix(components): [text] the title attribute loses its reactivity (#20875)

This commit is contained in:
betavs
2025-05-28 20:39:45 +08:00
committed by GitHub
parent feb21505b8
commit b35c3a54da

View File

@@ -34,12 +34,13 @@ const textKls = computed(() => [
ns.is('line-clamp', !isUndefined(props.lineClamp)),
])
const inheritTitle = useAttrs().title
const bindTitle = () => {
const inheritTitle = useAttrs().title
if (inheritTitle) return
let shouldAddTitle = false
const text = textRef.value?.textContent || ''
if (props.truncated) {
const width = textRef.value?.offsetWidth
const scrollWidth = textRef.value?.scrollWidth
@@ -53,6 +54,7 @@ const bindTitle = () => {
shouldAddTitle = true
}
}
if (shouldAddTitle) {
textRef.value?.setAttribute('title', text)
} else {