From 862a39dad37f3f3e8bc9962d2d33dd5a727115f6 Mon Sep 17 00:00:00 2001 From: Michael Prentice Date: Tue, 30 Oct 2018 15:45:01 -0400 Subject: [PATCH] fix(input): floating label text fails a11y contrast audit add special handling for Firefox placeholders add `::placeholder` to the list of pseudos remove duplicate `::-webkit-input-placeholder` add `::-ms-input-placeholder` for Edge fix demo a11y issues Relates to #11475 --- src/components/input/demoBasicUsage/index.html | 4 ++-- src/components/input/demoErrorsAdvanced/style.css | 2 +- src/components/input/demoIcons/index.html | 7 ++++--- src/components/input/input-theme.scss | 4 ++-- src/core/style/mixins.scss | 15 +++++++++++++-- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/components/input/demoBasicUsage/index.html b/src/components/input/demoBasicUsage/index.html index 4680f05a2d3..362ae856e32 100644 --- a/src/components/input/demoBasicUsage/index.html +++ b/src/components/input/demoBasicUsage/index.html @@ -26,7 +26,7 @@ - + @@ -48,7 +48,7 @@ - +
diff --git a/src/components/input/demoErrorsAdvanced/style.css b/src/components/input/demoErrorsAdvanced/style.css index 4dc9c08dcbe..f21caabbea9 100644 --- a/src/components/input/demoErrorsAdvanced/style.css +++ b/src/components/input/demoErrorsAdvanced/style.css @@ -11,7 +11,7 @@ transition: all 0.3s cubic-bezier(0.55, 0, 0.55, 0.2); /* Set our own color */ - color: grey; + color: rgba(0, 0, 0, 0.54); } /* NOTE: Check the demo's HTML to see some additional RTL support CSS */ diff --git a/src/components/input/demoIcons/index.html b/src/components/input/demoIcons/index.html index f4134dd4464..f8e23b5731a 100644 --- a/src/components/input/demoIcons/index.html +++ b/src/components/input/demoIcons/index.html @@ -11,17 +11,18 @@ - + - + - + diff --git a/src/components/input/input-theme.scss b/src/components/input/input-theme.scss index 539d96d68ab..cbdb16c6793 100644 --- a/src/components/input/input-theme.scss +++ b/src/components/input/input-theme.scss @@ -1,6 +1,6 @@ md-input-container.md-THEME_NAME-theme { .md-input { - @include input-placeholder-color('\'{{foreground-3}}\''); + @include input-placeholder-color('\'{{foreground-2}}\''); color: '{{foreground-1}}'; border-color: '{{foreground-4}}'; } @@ -11,7 +11,7 @@ md-input-container.md-THEME_NAME-theme { label, .md-placeholder { - color: '{{foreground-3}}'; + color: '{{foreground-2}}'; } label.md-required:after { diff --git a/src/core/style/mixins.scss b/src/core/style/mixins.scss index cafcb4478f9..ba924525a6f 100644 --- a/src/core/style/mixins.scss +++ b/src/core/style/mixins.scss @@ -15,8 +15,11 @@ } @mixin input-placeholder-color($color) { - $pseudos: '::-webkit-input-placeholder', ':-moz-placeholder', '::-moz-placeholder', - ':-ms-input-placeholder', '::-webkit-input-placeholder'; + $pseudos: '::-webkit-input-placeholder', // For QQ Browser + ':-ms-input-placeholder', // For IE + '::-ms-input-placeholder', // For Edge + '::placeholder'; + $firefox-pseudos: ':-moz-placeholder', '::-moz-placeholder'; // It is important to export every pseudo within its own block, because otherwise the placeholder // won't be set on the most browsers. @@ -25,6 +28,14 @@ color: unquote($color); } } + // Firefox reduces the opacity of placeholders so we need to keep them opaque to avoid applying + // double the transparency and causing a11y failures due to text contrast. + @each $pseudo in $firefox-pseudos { + &#{$pseudo} { + color: unquote($color); + opacity: 1; + } + } } @mixin pie-clearfix {