Skip to content

Commit 18bf69e

Browse files
authored
textarea: minheight + autosize (#3818)
1 parent c659343 commit 18bf69e

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/AddComment.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ export const AddComment: React.FC = () => {
4242
onChange={e => setValue(e.target.value)}
4343
onKeyDown={submitOnEnter}
4444
placeholder="Write a comment"
45-
css={css({ minHeight: 8 })}
46-
style={{ lineHeight: 1.2 }}
45+
style={{ lineHeight: 1.2, minHeight: 32 }}
4746
/>
4847
</FormField>
4948
</form>

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ const DialogAddComment: React.FC<{
183183
<DragHandle onPan={onDragHandlerPan}>
184184
<Stack
185185
justify="space-between"
186-
align="center"
187186
marginY={4}
188187
marginLeft={4}
189188
marginRight={2}
@@ -210,6 +209,7 @@ const DialogAddComment: React.FC<{
210209
border: 'none',
211210
paddingLeft: 4,
212211
})}
212+
style={{ minHeight: 32 }}
213213
value={value}
214214
onChange={e => setValue(e.target.value)}
215215
placeholder="Add comment..."
@@ -429,6 +429,7 @@ const AddReply = ({ comment, ...props }) => {
429429
borderRadius: 0,
430430
padding: 4,
431431
})}
432+
style={{ minHeight: 54 }}
432433
value={value}
433434
onChange={e => setValue(e.target.value)}
434435
placeholder="Reply..."

packages/components/src/components/Textarea/index.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
4151
export const Controlled = () => {
4252
const [value, setValue] = React.useState('');
4353
return (

packages/components/src/components/Textarea/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ export const Textarea: React.FC<ITextareaProps> = ({
7979
return (
8080
<>
8181
<Wrapper>
82-
<Autosize value={innerValue}>
82+
<Autosize value={innerValue} style={props.style}>
8383
{(height: number) => (
8484
<TextareaComponent
8585
value={innerValue}
8686
onChange={internalOnChange}
8787
maxLength={maxLength}
88-
style={{ height }}
8988
{...props}
89+
style={{ ...(props.style || {}), height }}
9090
/>
9191
)}
9292
</Autosize>
@@ -101,7 +101,7 @@ export const Textarea: React.FC<ITextareaProps> = ({
101101
);
102102
};
103103

104-
const Autosize = ({ value, ...props }) => (
104+
const Autosize = ({ value, style = {}, ...props }) => (
105105
<Rect>
106106
{({ rect, ref }) => (
107107
<>
@@ -116,6 +116,7 @@ const Autosize = ({ value, ...props }) => (
116116
lineHeight: 1,
117117
minHeight: 64,
118118
padding: 8,
119+
...style,
119120
}}
120121
>
121122
{value + ' '}

0 commit comments

Comments
 (0)