Skip to content

Commit 3aa5c94

Browse files
authored
fix(TextareaField): address QA updates (#1936)
- add bottom line for readonly field - move character counter to the top line of the component
1 parent e579367 commit 3aa5c94

File tree

3 files changed

+53
-43
lines changed

3 files changed

+53
-43
lines changed

src/components/TextareaField/TextareaField-v2.module.css

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
.textarea {
1414
@mixin inputStylesV2;
1515
padding: 0.5rem 0.75rem;
16+
17+
&:read-only:not(:disabled) {
18+
border: 0;
19+
border-bottom: 1px solid var(--eds-theme-color-border-utility-default-low-emphasis);
20+
}
1621
}
1722

1823
/**

src/components/TextareaField/TextareaField-v2.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ export const TextareaField: TextareaFieldType = forwardRef(
217217
styles['textarea-field--invalid-length'],
218218
);
219219

220+
const textareaClassName = clsx(
221+
readOnly && styles['textarea-field__textarea--read-only'],
222+
);
223+
220224
// Pick the smallest of the lengths to set as the maximum value allowed
221225
const maxLengthShown = getMinValue(maxLength, recommendedMaxLength);
222226

@@ -247,11 +251,18 @@ export const TextareaField: TextareaFieldType = forwardRef(
247251
(Optional)
248252
</Text>
249253
)}
254+
{maxLengthShown && (
255+
<div className={styles['textarea-field__character-counter']}>
256+
<span className={fieldLengthCountClassName}>{fieldLength}</span>{' '}
257+
/ {maxLengthShown}
258+
</div>
259+
)}
250260
</div>
251261
)}
252262
<TextArea
253263
aria-describedby={ariaDescribedByVar}
254264
aria-disabled={disabled}
265+
className={textareaClassName}
255266
defaultValue={defaultValue}
256267
disabled={disabled}
257268
id={idVar}
@@ -282,12 +293,6 @@ export const TextareaField: TextareaFieldType = forwardRef(
282293
{fieldNote}
283294
</FieldNote>
284295
)}
285-
{maxLengthShown && (
286-
<div className={styles['textarea-field__character-counter']}>
287-
<span className={fieldLengthCountClassName}>{fieldLength}</span>{' '}
288-
/ {maxLengthShown}
289-
</div>
290-
)}
291296
</div>
292297
)}
293298
</div>

src/components/TextareaField/__snapshots__/TextareaField-v2.test.tsx.snap

+37-37
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ exports[`<TextareaField /> WhenReadOnly story renders snapshot 1`] = `
244244
</div>
245245
<textarea
246246
aria-describedby=":r9:"
247-
class="textarea"
247+
class="textarea textarea-field__textarea--read-only"
248248
id=":r8:"
249249
placeholder="Enter long-form text here"
250250
readonly=""
@@ -480,6 +480,18 @@ exports[`<TextareaField /> WithAMaxLength story renders snapshot 1`] = `
480480
>
481481
Textarea Field
482482
</label>
483+
<div
484+
class="textarea-field__character-counter"
485+
>
486+
<span
487+
class="textarea-field--invalid-length"
488+
>
489+
202
490+
</span>
491+
492+
/
493+
144
494+
</div>
483495
</div>
484496
<textarea
485497
aria-describedby=":rl:"
@@ -521,18 +533,6 @@ praesentium, commodi eligendi asperiores quis dolorum porro.
521533
</svg>
522534
Longer Field description
523535
</div>
524-
<div
525-
class="textarea-field__character-counter"
526-
>
527-
<span
528-
class="textarea-field--invalid-length"
529-
>
530-
202
531-
</span>
532-
533-
/
534-
144
535-
</div>
536536
</div>
537537
</div>
538538
</div>
@@ -554,6 +554,18 @@ exports[`<TextareaField /> WithARecommendedLength story renders snapshot 1`] = `
554554
>
555555
Textarea Field
556556
</label>
557+
<div
558+
class="textarea-field__character-counter"
559+
>
560+
<span
561+
class="textarea-field--invalid-length"
562+
>
563+
202
564+
</span>
565+
566+
/
567+
144
568+
</div>
557569
</div>
558570
<textarea
559571
aria-describedby=":rn:"
@@ -594,18 +606,6 @@ praesentium, commodi eligendi asperiores quis dolorum porro.
594606
</svg>
595607
Longer Field description
596608
</div>
597-
<div
598-
class="textarea-field__character-counter"
599-
>
600-
<span
601-
class="textarea-field--invalid-length"
602-
>
603-
202
604-
</span>
605-
606-
/
607-
144
608-
</div>
609609
</div>
610610
</div>
611611
</div>
@@ -627,6 +627,18 @@ exports[`<TextareaField /> WithBothRecommendedAndMaxLengths story renders snapsh
627627
>
628628
Textarea Field
629629
</label>
630+
<div
631+
class="textarea-field__character-counter"
632+
>
633+
<span
634+
class="textarea-field--invalid-length"
635+
>
636+
202
637+
</span>
638+
639+
/
640+
144
641+
</div>
630642
</div>
631643
<textarea
632644
aria-describedby=":rp:"
@@ -668,18 +680,6 @@ praesentium, commodi eligendi asperiores quis dolorum porro.
668680
</svg>
669681
Longer Field description
670682
</div>
671-
<div
672-
class="textarea-field__character-counter"
673-
>
674-
<span
675-
class="textarea-field--invalid-length"
676-
>
677-
202
678-
</span>
679-
680-
/
681-
144
682-
</div>
683683
</div>
684684
</div>
685685
</div>

0 commit comments

Comments
 (0)