File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
packages/ui/src/fields/Textarea Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 1
1
'use client'
2
+ import type { CSSProperties } from 'react'
3
+
2
4
import { getTranslation } from '@payloadcms/translations'
3
5
import React from 'react'
4
6
@@ -53,7 +55,13 @@ export const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
53
55
< RenderCustomComponent
54
56
CustomComponent = { Label }
55
57
Fallback = {
56
- < FieldLabel label = { label } localized = { localized } path = { path } required = { required } />
58
+ < FieldLabel
59
+ htmlFor = { `field-${ path . replace ( / \. / g, '__' ) } ` }
60
+ label = { label }
61
+ localized = { localized }
62
+ path = { path }
63
+ required = { required }
64
+ />
57
65
}
58
66
/>
59
67
< div className = { `${ fieldBaseClass } __wrap` } >
@@ -62,7 +70,7 @@ export const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
62
70
Fallback = { < FieldError path = { path } showError = { showError } /> }
63
71
/>
64
72
{ BeforeInput }
65
- < label className = "textarea-outer" htmlFor = { `field- ${ path . replace ( / \. / g , '__' ) } ` } >
73
+ < div className = "textarea-outer" >
66
74
< textarea
67
75
data-rtl = { rtl }
68
76
disabled = { readOnly }
@@ -71,9 +79,14 @@ export const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
71
79
onChange = { onChange }
72
80
placeholder = { getTranslation ( placeholder , i18n ) }
73
81
rows = { rows }
82
+ style = {
83
+ {
84
+ '--rows' : rows ,
85
+ } as CSSProperties
86
+ }
74
87
value = { value || '' }
75
88
/>
76
- </ label >
89
+ </ div >
77
90
{ AfterInput }
78
91
< RenderCustomComponent
79
92
CustomComponent = { Description }
Original file line number Diff line number Diff line change 8
8
9
9
textarea {
10
10
@include formInput ();
11
- field-sizing : content ;
12
11
overflow-y : auto ;
13
12
resize : vertical ;
14
13
min-height : base (3 );
15
- height : 100 % ;
14
+ height : auto ;
16
15
display : flex ;
17
16
}
18
17
18
+ textarea :not (:empty ) {
19
+ field-sizing : content ;
20
+ min-height : calc (var (--rows ) * var (--base ) + var (--base ) * 0.8 + 2px );
21
+ }
22
+
19
23
& .read-only {
20
24
.textarea-outer {
21
25
@include readOnly ;
22
26
}
23
27
}
24
-
25
28
}
26
29
27
30
html [data-theme = ' light' ] {
You can’t perform that action at this time.
0 commit comments