fix(components): [input] textarea height calc (#12087)

This commit is contained in:
井柏然 2023-03-24 00:42:16 +08:00 committed by GitHub
parent eb88722841
commit 6c20f21831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -313,6 +313,7 @@ const suffixVisible = computed(
const [recordCursor, setCursor] = useCursor(input)
useResizeObserver(textarea, (entries) => {
onceInitSizeTextarea()
if (!isWordLimitVisible.value || props.resize !== 'both') return
const entry = entries[0]
const { width } = entry.contentRect
@ -353,6 +354,20 @@ const resizeTextarea = () => {
}
}
const createOnceInitResize = (resizeTextarea: () => void) => {
let isInit = false
return () => {
if (isInit || !props.autosize) return
const isElHidden = textarea.value?.offsetParent === null
if (!isElHidden) {
resizeTextarea()
isInit = true
}
}
}
// fix: https://github.com/element-plus/element-plus/issues/12074
const onceInitSizeTextarea = createOnceInitResize(resizeTextarea)
const setNativeInputValue = () => {
const input = _ref.value
if (!input || input.value === nativeInputValue.value) return