Skip to content

Commit

Permalink
Merge pull request #19129 from sephit/dev
Browse files Browse the repository at this point in the history
Avoid classes if input is hidden
  • Loading branch information
realLiangshiwei committed Feb 26, 2024
2 parents d746408 + f2591e9 commit 890b12b
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,22 @@ out var suppress
output.TagMode = TagMode.StartTagAndEndTag;
output.TagName = "div";
LeaveOnlyGroupAttributes(context, output);
if (TagHelper.FloatingLabel && !isCheckBox)
if (!IsOutputHidden(output))
{
output.Attributes.AddClass("form-floating");
}
if (TagHelper.AddMarginBottomClass)
{
output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3");
}
if (isCheckBox)
{
output.Attributes.AddClass("custom-checkbox");
output.Attributes.AddClass("custom-control");
output.Attributes.AddClass("form-check");
if (TagHelper.FloatingLabel && !isCheckBox)
{
output.Attributes.AddClass("form-floating");
}
if (TagHelper.AddMarginBottomClass)
{
output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3");
}
if (isCheckBox)
{
output.Attributes.AddClass("custom-checkbox");
output.Attributes.AddClass("custom-control");
output.Attributes.AddClass("form-check");
}
}
output.Content.AppendHtml(innerHtml);
}
Expand Down Expand Up @@ -263,7 +266,7 @@ protected virtual bool IsInputCheckbox(TagHelperContext context, TagHelperOutput
}

protected virtual async Task<string> GetLabelAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag, bool isCheckbox)
{
{
if (IsOutputHidden(inputTag) || TagHelper.SuppressLabel)
{
return string.Empty;
Expand Down

0 comments on commit 890b12b

Please sign in to comment.