File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
packages/components/src/components/Textarea Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,16 @@ export const autoResize = () => (
3838 </ Wrapper >
3939) ;
4040
41+ export const autoResizeWithInitialHeight = ( ) => (
42+ < Wrapper >
43+ < Textarea
44+ autosize
45+ placeholder = "Write a lot of lines here"
46+ style = { { minHeight : 32 } }
47+ />
48+ </ Wrapper >
49+ ) ;
50+
4151export const Controlled = ( ) => {
4252 const [ value , setValue ] = React . useState ( '' ) ;
4353 return (
Original file line number Diff line number Diff line change @@ -47,7 +47,6 @@ export const Textarea: React.FC<ITextareaProps> = ({
4747 ...props
4848} ) => {
4949 const [ innerValue , setInnerValue ] = React . useState < string > ( defaultValue ) ;
50-
5150 /**
5251 * To support both contolled and uncontrolled components
5352 * We sync props.value with internalValue
@@ -79,14 +78,14 @@ export const Textarea: React.FC<ITextareaProps> = ({
7978 return (
8079 < >
8180 < Wrapper >
82- < Autosize value = { innerValue } >
81+ < Autosize value = { innerValue } style = { props . style } >
8382 { ( height : number ) => (
8483 < TextareaComponent
8584 value = { innerValue }
8685 onChange = { internalOnChange }
8786 maxLength = { maxLength }
88- style = { { height } }
8987 { ...props }
88+ style = { { ...( props . style || { } ) , height } }
9089 />
9190 ) }
9291 </ Autosize >
@@ -101,7 +100,7 @@ export const Textarea: React.FC<ITextareaProps> = ({
101100 ) ;
102101} ;
103102
104- const Autosize = ( { value, ...props } ) => (
103+ const Autosize = ( { value, style = { } , ...props } ) => (
105104 < Rect >
106105 { ( { rect, ref } ) => (
107106 < >
@@ -116,6 +115,7 @@ const Autosize = ({ value, ...props }) => (
116115 lineHeight : 1 ,
117116 minHeight : 64 ,
118117 padding : 8 ,
118+ ...style ,
119119 } }
120120 >
121121 { value + ' ' }
You can’t perform that action at this time.
0 commit comments