Skip to content

Commit e275dcb

Browse files
authored
fix(form): support inline fields group label for required attribute
A required Inline fields label does not get an asterisk and does not get a state color To fix the state color i had to make use of the :has() class selector. This isnt supported by all browsers, so in those browsers this feature wont work. I also fixed positioning of fields when an empty label is used
1 parent 5da44d8 commit e275dcb

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/definitions/behaviors/form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@
643643
var $field = typeof identifier === 'string'
644644
? module.get.field(identifier)
645645
: identifier,
646-
$label = $field.closest(selector.group).find('label').eq(0)
646+
$label = $field.closest(selector.group).find('label:not(:empty)').eq(0)
647647
;
648648

649649
return $label.length === 1

src/definitions/collections/form.less

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@
527527
color: @c;
528528
}
529529

530+
// needs separate selector because not supported by every browser
531+
.ui.form .fields:has(.@{state}) > label {
532+
color: @c;
533+
}
534+
530535
.ui.form .fields.@{state} .field .ui.label,
531536
.ui.form .field.@{state} .ui.label {
532537
background-color: @lbg;
@@ -729,6 +734,11 @@
729734
.ui.inverted.form .@{state}.field label {
730735
color: @lbg;
731736
}
737+
738+
// needs separate selector because not supported by every browser
739+
.ui.inverted.form .fields:has(.@{state}) > label {
740+
color: @lbg;
741+
}
732742
}
733743
});
734744
}
@@ -804,33 +814,41 @@
804814
Required Field
805815
--------------------- */
806816

807-
.ui.form .required.fields:not(.grouped) > .field > label::after,
817+
.ui.form .required.fields:not(.grouped):not(.inline) > .field > label::after,
818+
.ui.form .required.fields.inline > label::after,
808819
.ui.form .required.fields.grouped > label::after,
809820
.ui.form .required.field > label::after,
810-
.ui.form .required.fields:not(.grouped) > .field > .checkbox::after,
821+
.ui.form .required.fields:not(.grouped):not(.inline) > .field > .checkbox::after,
811822
.ui.form .required.field > .checkbox::after,
812823
.ui.form label.required::after {
813824
margin: @requiredMargin;
814825
content: @requiredContent;
815826
color: @requiredColor;
816827
}
817828

818-
.ui.form .required.fields:not(.grouped) > .field > label::after,
829+
.ui.form .required.fields:not(.grouped):not(.inline) > .field > label::after,
830+
.ui.form .required.fields.inline > label::after,
819831
.ui.form .required.fields.grouped > label::after,
820832
.ui.form .required.field > label::after,
821833
.ui.form label.required::after {
822834
display: inline-block;
823835
vertical-align: top;
824836
}
825837

826-
.ui.form .required.fields:not(.grouped) > .field > .checkbox::after,
838+
.ui.form .required.fields:not(.grouped):not(.inline) > .field > .checkbox::after,
827839
.ui.form .required.field > .checkbox::after {
828840
position: absolute;
829841
top: 0;
830842
left: 100%;
831843
}
832844
}
833845

846+
.ui.ui.ui.ui.form .fields > label:empty::after,
847+
.ui.ui.ui.ui.form .field > label:empty::after {
848+
content: " ";
849+
display: inline-block;
850+
}
851+
834852
/*******************************
835853
Variations
836854
*******************************/

0 commit comments

Comments
 (0)