GrowingTextarea: initial value fix (#228)
This commit is contained in:
parent
42493c2e98
commit
a9b67ff9ff
|
@ -20,7 +20,7 @@ export const GrowingTextarea = (props: Props) => {
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (props.maxLength && props.initialValue?.length > props.maxLength) {
|
if (props.maxLength && props.initialValue?.length > props.maxLength) {
|
||||||
setValue(props.initialValue.slice(0, props.maxLength))
|
setValue(props.initialValue?.slice(0, props.maxLength))
|
||||||
} else {
|
} else {
|
||||||
setValue(props.initialValue ?? '')
|
setValue(props.initialValue ?? '')
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ export const GrowingTextarea = (props: Props) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('!!! initialValue:', props.initialValue)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class={clsx(styles.GrowingTextarea, {
|
class={clsx(styles.GrowingTextarea, {
|
||||||
|
@ -56,7 +58,11 @@ export const GrowingTextarea = (props: Props) => {
|
||||||
maxlength={props.maxLength}
|
maxlength={props.maxLength}
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
class={clsx(styles.textInput, props.class)}
|
class={clsx(styles.textInput, props.class)}
|
||||||
value={props.maxLength ? props.initialValue.slice(0, props.maxLength) : props.initialValue}
|
value={
|
||||||
|
props.initialValue && props.maxLength
|
||||||
|
? props.initialValue?.slice(0, props.maxLength)
|
||||||
|
: props.initialValue
|
||||||
|
}
|
||||||
onKeyDown={props.allowEnterKey ? handleKeyDown : null}
|
onKeyDown={props.allowEnterKey ? handleKeyDown : null}
|
||||||
onInput={(event) => handleChangeValue(event)}
|
onInput={(event) => handleChangeValue(event)}
|
||||||
onChange={(event) => props.value(event.target.value)}
|
onChange={(event) => props.value(event.target.value)}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user