mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-17 21:32:51 +08:00
fix(components): [input] textarea height calc (#12087)
This commit is contained in:
@ -313,6 +313,7 @@ const suffixVisible = computed(
|
|||||||
const [recordCursor, setCursor] = useCursor(input)
|
const [recordCursor, setCursor] = useCursor(input)
|
||||||
|
|
||||||
useResizeObserver(textarea, (entries) => {
|
useResizeObserver(textarea, (entries) => {
|
||||||
|
onceInitSizeTextarea()
|
||||||
if (!isWordLimitVisible.value || props.resize !== 'both') return
|
if (!isWordLimitVisible.value || props.resize !== 'both') return
|
||||||
const entry = entries[0]
|
const entry = entries[0]
|
||||||
const { width } = entry.contentRect
|
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 setNativeInputValue = () => {
|
||||||
const input = _ref.value
|
const input = _ref.value
|
||||||
if (!input || input.value === nativeInputValue.value) return
|
if (!input || input.value === nativeInputValue.value) return
|
||||||
|
Reference in New Issue
Block a user