The label no longer being hidden is impacted by the Summer '18 change where many base lightning components no longer automatically include the slds-form_inline
or slds-form--inline
CSS class.
Per the release notes:
The slds-form_inline (formerly slds-form--inline) style was removed. When applied, the style made the element’s width unchangeable.
Where: This change affects Lightning components that support the label-hidden
variant: lightning:input
, lightning:combobox
, lightning:dualListbox
, lightning:radioGroup
, lightning:select
, and lightning:textarea
. The style is no longer applied when you use the label-hidden
variant, but you shouldn’t notice a difference in the rendering of the components in most cases.
Why: The slds-form_inline style was mistakenly applied by the label-hidden variant.
I'm not sure what scenarios the statement "you shouldn’t notice a difference in the rendering of the components in most cases." refers to, but when using variant: label-hidden this change has visible differences compared to earlier versions of Salesforce.
Workarounds
Option 1. (recommended) Add custom component styling
I recommend this option as you avoid any of the negative side effects for why Salesforce removed usage of the slds-form_line
class but you get the benefit of hiding the label, which is the desired effect.
Assign a custom class to your input component (I chose to name my class 'label-hidden' after the variant) and then add styling for it in your component's style resource.
YourComponent.cmp
<lightning:select
label="Select Account"
variant="label-hidden"
class="label-hidden"
value="{!v.selectedAccountId}">
...
</lightning:select>
YourComponent.css
.THIS .label-hidden > label {
display: none;
}
Option 2. Add back the class slds-form_line
to your component
This approach tries to reproduce the original behavior pre Summer '18, but you maintain any of the negative reasons why Salesforce decided to remove its usage. However, you don't have to create a custom style resource for your component.
YourComponent.cmp
<lightning:select
label="Select Account"
variant="label-hidden"
class="slds-form_inline"
value="{!v.selectedAccountId}">
...
</lightning:select>