mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-04 20:27:44 +08:00
fix(components): [input] textarea height calc (#12087)
This commit is contained in:
parent
eb88722841
commit
6c20f21831
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user