Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent form validation mixin from generating invalid CSS #28447

Merged
merged 4 commits into from
Apr 25, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions scss/mixins/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
@include deprecate("The `form-control-focus()` mixin", "v4.3.2", "v5", $ignore-warning);
}

@mixin form-validation-state-selector($state) {
@if ($state == "valid" or $state == "invalid") {
.was-validated &:#{$state},
&.is-#{$state} {
@content;
}
} @else {
&.is-#{$state} {
@content;
}
}
}

@mixin form-validation-state($state, $color, $icon) {
.#{$state}-feedback {
Expand All @@ -52,8 +64,7 @@
}

.form-control {
.was-validated &:#{$state},
&.is-#{$state} {
@include form-validation-state-selector($state) {
border-color: $color;

@if $enable-validation-icons {
Expand All @@ -78,8 +89,7 @@

// stylelint-disable-next-line selector-no-qualifying-type
textarea.form-control {
.was-validated &:#{$state},
&.is-#{$state} {
@include form-validation-state-selector($state) {
@if $enable-validation-icons {
padding-right: $input-height-inner;
background-position: top $input-height-inner-quarter right $input-height-inner-quarter;
Expand All @@ -88,8 +98,7 @@
}

.custom-select {
.was-validated &:#{$state},
&.is-#{$state} {
@include form-validation-state-selector($state) {
border-color: $color;

@if $enable-validation-icons {
Expand All @@ -111,8 +120,7 @@


.form-control-file {
.was-validated &:#{$state},
&.is-#{$state} {
@include form-validation-state-selector($state) {
~ .#{$state}-feedback,
~ .#{$state}-tooltip {
display: block;
Expand All @@ -121,8 +129,7 @@
}

.form-check-input {
.was-validated &:#{$state},
&.is-#{$state} {
@include form-validation-state-selector($state) {
~ .form-check-label {
color: $color;
}
Expand All @@ -135,8 +142,7 @@
}

.custom-control-input {
.was-validated &:#{$state},
&.is-#{$state} {
@include form-validation-state-selector($state) {
~ .custom-control-label {
color: $color;

Expand Down Expand Up @@ -171,8 +177,7 @@

// custom file
.custom-file-input {
.was-validated &:#{$state},
&.is-#{$state} {
@include form-validation-state-selector($state) {
~ .custom-file-label {
border-color: $color;
}
Expand Down