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 11'use client'
2+ import type { CSSProperties } from 'react'
3+
24import { getTranslation } from '@payloadcms/translations'
35import React from 'react'
46
@@ -53,7 +55,13 @@ export const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
5355 < RenderCustomComponent
5456 CustomComponent = { Label }
5557 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+ />
5765 }
5866 />
5967 < div className = { `${ fieldBaseClass } __wrap` } >
@@ -62,7 +70,7 @@ export const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
6270 Fallback = { < FieldError path = { path } showError = { showError } /> }
6371 />
6472 { BeforeInput }
65- < label className = "textarea-outer" htmlFor = { `field- ${ path . replace ( / \. / g , '__' ) } ` } >
73+ < div className = "textarea-outer" >
6674 < textarea
6775 data-rtl = { rtl }
6876 disabled = { readOnly }
@@ -71,9 +79,14 @@ export const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
7179 onChange = { onChange }
7280 placeholder = { getTranslation ( placeholder , i18n ) }
7381 rows = { rows }
82+ style = {
83+ {
84+ '--rows' : rows ,
85+ } as CSSProperties
86+ }
7487 value = { value || '' }
7588 />
76- </ label >
89+ </ div >
7790 { AfterInput }
7891 < RenderCustomComponent
7992 CustomComponent = { Description }
Original file line number Diff line number Diff line change 88
99 textarea {
1010 @include formInput ();
11- field-sizing : content ;
1211 overflow-y : auto ;
1312 resize : vertical ;
1413 min-height : base (3 );
15- height : 100 % ;
14+ height : auto ;
1615 display : flex ;
1716 }
1817
18+ textarea :not (:empty ) {
19+ field-sizing : content ;
20+ min-height : calc (var (--rows ) * var (--base ) + var (--base ) * 0.8 + 2px );
21+ }
22+
1923 & .read-only {
2024 .textarea-outer {
2125 @include readOnly ;
2226 }
2327 }
24-
2528 }
2629
2730 html [data-theme = ' light' ] {
You can’t perform that action at this time.
0 commit comments