I am trying to add dynamic style one of lightning layout, the code goes till the device identification yet it doesn't apply the proper style.
Here is my code:-
<lightning:layout aura:id="instructionsPane" class="slds-p-around_small">
Controller:
applyDynamicStyles : function(component,event){
var device = $A.get("$Browser.formFactor");
console.log('device--->'+device);
var instructionsPane = component.find('instructionsPane');
if(device == 'PHONE'){
$A.util.addClass(instructionsPane, 'slds-border_top');
}
else{
console.log('InsideDesktop adding class to Instructions pane');
$A.util.addClass(instructionsPane, 'slds-border_left');
}
}
Same thing works properly when I apply in static,however I need make it dynamic based on device.
afterRender()
.render
event instead?$Browser.formFactor
is having issues with Winter '20. We have an implementation where we are using similar approach to identify the device and it is not working (used to work prior to Winter '20). We have opened a case to Salesforce and are still waiting to hear back. This could be possibly the same issue. I will update once I hear back.