diff --git a/field/lib/_content.scss b/field/lib/_content.scss
index a63cf2b9ea0..8a0598cb76f 100644
--- a/field/lib/_content.scss
+++ b/field/lib/_content.scss
@@ -95,9 +95,18 @@ $_enter-delay: $_label-duration - $_visible-duration;
// below.
color: currentColor;
font: var(--_content-type);
+ width: 100%;
+ }
+
+ .content ::slotted(:not(textarea)) {
padding-top: var(--_top-space);
padding-bottom: var(--_bottom-space);
- width: 100%;
+ }
+
+ .content ::slotted(textarea) {
+ // Use margin for textareas since they will scroll over the label if not.
+ margin-top: var(--_top-space);
+ margin-bottom: var(--_bottom-space);
}
:hover .content {
diff --git a/field/lib/_filled-field.scss b/field/lib/_filled-field.scss
index 00c36811bec..4ec29a3da1c 100644
--- a/field/lib/_filled-field.scss
+++ b/field/lib/_filled-field.scss
@@ -95,11 +95,11 @@ $_md-sys-motion: tokens.md-sys-motion-values();
top: var(--_with-label-top-space);
}
- .field:not(.with-start) .label-space {
+ .field:not(.with-start) .label-wrapper {
margin-inline-start: var(--_leading-space);
}
- .field:not(.with-end) .label-space {
+ .field:not(.with-end) .label-wrapper {
margin-inline-end: var(--_trailing-space);
}
@@ -141,13 +141,21 @@ $_md-sys-motion: tokens.md-sys-motion-values();
padding-inline-end: var(--_trailing-space);
}
- .field:not(.no-label) .content ::slotted(*) {
+ .field:not(.no-label) .content ::slotted(:not(textarea)) {
padding-bottom: var(--_with-label-bottom-space);
padding-top: calc(
var(--_with-label-top-space) + var(--_label-text-populated-line-height)
);
}
+ .field:not(.no-label) .content ::slotted(textarea) {
+ // Use margin for textareas since they will scroll over the label if not.
+ margin-bottom: var(--_with-label-bottom-space);
+ margin-top: calc(
+ var(--_with-label-top-space) + var(--_label-text-populated-line-height)
+ );
+ }
+
:hover .active-indicator::before {
border-bottom-color: var(--_hover-active-indicator-color);
border-bottom-width: var(--_hover-active-indicator-height);
diff --git a/field/lib/_label.scss b/field/lib/_label.scss
index 9f2dff3f3b9..8af24169cf2 100644
--- a/field/lib/_label.scss
+++ b/field/lib/_label.scss
@@ -9,13 +9,6 @@
color: var(--_label-text-color);
overflow: hidden;
max-width: 100%;
- // The resting label at 100% height can block pointer events to the content
- // if it's very long and spans the full width of the field. Additionally,
- // selecting the label's text doesn't present a good UX, since the user
- // selection should be re-focused to another element (such as the input)
- // upon focusing. Finally, since the actual label elements are swapped, it
- // is not easy to maintain the user's label text selection.
- pointer-events: none;
// TODO: Check with design, should there be any transition from resting to
// floating when there is a mismatch between ellipsis, such as opacity
// transition?
@@ -26,6 +19,18 @@
width: min-content;
}
+ .label-wrapper {
+ inset: 0;
+ // The resting label at 100% height can block pointer events to the content
+ // if it's very long and spans the full width of the field. Additionally,
+ // selecting the label's text doesn't present a good UX, since the user
+ // selection should be re-focused to another element (such as the input)
+ // upon focusing. Finally, since the actual label elements are swapped, it
+ // is not easy to maintain the user's label text selection.
+ pointer-events: none;
+ position: absolute;
+ }
+
.label.resting {
position: absolute;
top: var(--_top-space);
@@ -48,7 +53,7 @@
// Labels need start/end padding when there isn't start/end content so they
// don't sit on the edge of the field. We use a wrapper element around the
// labels so as not to affect the dimensions used in the label keyframes.
- .label-space {
+ .label-wrapper {
inset: 0;
position: absolute;
// Don't let setting text-align on the field change the label's alignment.
diff --git a/field/lib/_outlined-field.scss b/field/lib/_outlined-field.scss
index f1dfb30d5e3..9bcbf7961b9 100644
--- a/field/lib/_outlined-field.scss
+++ b/field/lib/_outlined-field.scss
@@ -237,7 +237,7 @@ $_md-sys-motion: tokens.md-sys-motion-values();
padding-inline-start: $start-space;
}
- .field:not(.with-start) .label-space {
+ .field:not(.with-start) .label-wrapper {
margin-inline-start: $start-space;
}
@@ -245,7 +245,7 @@ $_md-sys-motion: tokens.md-sys-motion-values();
padding-inline-end: $end-space;
}
- .field:not(.with-end) .label-space {
+ .field:not(.with-end) .label-wrapper {
margin-inline-end: $end-space;
}
diff --git a/field/lib/_shared.scss b/field/lib/_shared.scss
index 0f7ca3da8a2..e3045f7d815 100644
--- a/field/lib/_shared.scss
+++ b/field/lib/_shared.scss
@@ -44,6 +44,7 @@
border-radius: inherit;
display: flex;
flex: 1;
+ min-height: 100%;
min-width: min-content;
overflow: hidden;
position: relative;
@@ -52,6 +53,7 @@
.field,
.container-overflow,
.container {
+ height: 100%;
resize: inherit;
}
diff --git a/field/lib/field.ts b/field/lib/field.ts
index 4026d38a73e..fc1abcb5b0d 100644
--- a/field/lib/field.ts
+++ b/field/lib/field.ts
@@ -116,7 +116,7 @@ export class Field extends LitElement implements SurfacePositionTarget {