修改标题对齐问题

This commit is contained in:
筱野
2025-12-10 22:14:08 +08:00
parent 57d1b9446b
commit 28201d79b9
2 changed files with 66 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
import React, { useCallback } from 'react'
import React, { useCallback, useState } from 'react'
import { View } from '@tarojs/components'
import { TextArea } from '@nutui/nutui-react-taro';
@@ -22,27 +22,49 @@ const TitleTextarea: React.FC<TitleTextareaProps> = ({
onBlur
}) => {
const isOverflow = value.length > maxLength
// const [isFocused, setIsFocused] = useState(false)
// const showPlaceholder = !isFocused && !value
const handleChange = useCallback((values) => {
// if (values.length > maxLength ) {
// const newValues = values.slice(0, maxLength)
// onChange(newValues)
// return;
// }
onChange(values)
}, [])
onChange(values)
}, [onChange])
const handleFocus = useCallback(() => {
// setIsFocused(true)
onFocus?.()
}, [onFocus])
const handleBlur = useCallback(() => {
// setIsFocused(false)
onBlur?.()
}, [onBlur])
return (
<View className='title-input-wrapper'>
<TextArea
className='title-input'
placeholder={placeholder}
value={value}
onInput={(e) => handleChange(e.detail.value)}
// maxlength={maxLength}
autoSize={true}
placeholderClass='title-input-placeholder'
onFocus={onFocus}
onBlur={onBlur}
/>
<View className='title-input-box'>
<TextArea
className='title-input'
placeholder={placeholder}
value={value}
onInput={(e) => handleChange(e.detail.value)}
// maxlength={maxLength}
placeholderClass='title-input-placeholder'
autoSize={true}
onFocus={handleFocus}
onBlur={handleBlur}
/>
{/* {showPlaceholder && (
<View className='title-input-placeholder-custom'>
{placeholder}
</View>
)} */}
</View>
<View className={`char-count${isOverflow ? ' char-count--error' : ''}`}>
{value.length}/{maxLength}
</View>