From 6e3c0c3ba106633d74dada62828ce781847a2d41 Mon Sep 17 00:00:00 2001
From: Miles Malerba
Date: Sat, 8 Apr 2017 10:32:43 -0700
Subject: [PATCH] fix(input): make start and end hints interact well when their
text needs to wrap
---
src/demo-app/input/input-demo.html | 9 ++++++++
src/lib/input/input-container.html | 4 +++-
src/lib/input/input-container.scss | 33 ++++--------------------------
3 files changed, 16 insertions(+), 30 deletions(-)
diff --git a/src/demo-app/input/input-demo.html b/src/demo-app/input/input-demo.html
index 7898932b2d5f..bc54fe83ce38 100644
--- a/src/demo-app/input/input-demo.html
+++ b/src/demo-app/input/input-demo.html
@@ -221,6 +221,15 @@ Textarea
{{hintLabelWithCharCount.value.length}}
+
+
+
+
+ Enter some text to count how many characters are in it. The character count is shown on the right.
+
+ Length: {{longHint.value.length}}
+
+
Check to change the color:
diff --git a/src/lib/input/input-container.html b/src/lib/input/input-container.html
index 56c748b33162..451641b777dc 100644
--- a/src/lib/input/input-container.html
+++ b/src/lib/input/input-container.html
@@ -44,7 +44,9 @@
diff --git a/src/lib/input/input-container.scss b/src/lib/input/input-container.scss
index b43c8b6f149b..b8b472861483 100644
--- a/src/lib/input/input-container.scss
+++ b/src/lib/input/input-container.scss
@@ -5,6 +5,7 @@
$mat-input-floating-placeholder-scale-factor: 0.75 !default;
$mat-input-wrapper-spacing: 1em !default;
+$mat-input-hint-min-space: 10px !default;
// Gradient for showing the dashed line when the input is disabled.
$mat-input-underline-disabled-background-image:
@@ -236,37 +237,11 @@ $mat-input-underline-disabled-background-image:
// Clears the floats on the hints. This is necessary for the hint animation to work.
.mat-input-hint-wrapper {
- &::before,
- &::after {
- content: ' ';
- display: table;
- }
-
- &::after {
- clear: both;
- }
+ display: flex;
}
-// The hint is shown below the underline. There can be
-// more than one; one at the start and one at the end.
-.mat-hint {
- display: block;
- float: left;
-
- // We use floats here, as opposed to flexbox, in order to make it
- // easier to reverse their location in rtl and to ensure that they're
- // aligned properly in some cases (e.g. when there is only an `end` hint).
- &.mat-right {
- float: right;
- }
-
- [dir='rtl'] & {
- float: right;
-
- &.mat-right {
- float: left;
- }
- }
+.mat-input-hint-spacer {
+ flex: 1 0 $mat-input-hint-min-space;
}
// Single error message displayed beneath the input.