• Bhskar Nori
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi All !
 
In the lightning record edit form/view form I have some custom fields where I have used label and formatted text tags to show the fields in UI. These custom fields are always displayed in comfy layout ( stacked) while the other fields which are displayed using <lightning-input-field> or<lightning-output-field> tags are dynamically aligning to the users display density by adding 'slds-form-element_horizontal' (in case of compact display density) or 'slds-form-element_stacked'(in case of comfy display  density) class to their respective div tags. When the user selects compact layout discrepancy between these two types of fields is observed.
 
I have gone through the similar question in Stack Exchange in the below URL but the three Answers provided there didn't solve my problem. Please find my comments below on why those Answers didn't solve the issue.
 
https://salesforce.stackexchange.com/questions/234780/how-to-get-the-display-density-in-a-lightning-components-controller
 
Answer 1 - Using /ui-api/themes/active  : This provides only Salesforce org’s active theme but not the individual user's display density.
Answer 2 - Using variable density slds classes : This Solves the spacing issue but will not align the fields from stacked to horizontal based on display density.
Answer 3 - Using renderedCallBack : By calling the content inside the rendered callback( as mentioned in above link) with a setTimeOut of 1 second I was able to identify '.slds-form-element_horizontal' class and able to dynamically change CSS for my custom fields. If I didn't add the setTimeOut of 1 second I was not able to identify '.slds-form-element_horizontal' class in the compact layout.
 
But the 3rd approach does not seems to be the robust approach to solve the problem as It depends identifying '.slds-form-element_horizontal' class and the setTimeOut to determine the display density.
 
Is there any better approach to identifying users display density dynamically in LWC ?
Hi All !
 
In the lightning record edit form/view form I have some custom fields where I have used label and formatted text tags to show the fields in UI. These custom fields are always displayed in comfy layout ( stacked) while the other fields which are displayed using <lightning-input-field> or<lightning-output-field> tags are dynamically aligning to the users display density by adding 'slds-form-element_horizontal' (in case of compact display density) or 'slds-form-element_stacked'(in case of comfy display  density) class to their respective div tags. When the user selects compact layout discrepancy between these two types of fields is observed.
 
I have gone through the similar question in Stack Exchange in the below URL but the three Answers provided there didn't solve my problem. Please find my comments below on why those Answers didn't solve the issue.
 
https://salesforce.stackexchange.com/questions/234780/how-to-get-the-display-density-in-a-lightning-components-controller
 
Answer 1 - Using /ui-api/themes/active  : This provides only Salesforce org’s active theme but not the individual user's display density.
Answer 2 - Using variable density slds classes : This Solves the spacing issue but will not align the fields from stacked to horizontal based on display density.
Answer 3 - Using renderedCallBack : By calling the content inside the rendered callback( as mentioned in above link) with a setTimeOut of 1 second I was able to identify '.slds-form-element_horizontal' class and able to dynamically change CSS for my custom fields. If I didn't add the setTimeOut of 1 second I was not able to identify '.slds-form-element_horizontal' class in the compact layout.
 
But the 3rd approach does not seems to be the robust approach to solve the problem as It depends identifying '.slds-form-element_horizontal' class and the setTimeOut to determine the display density.
 
Is there any better approach to identifying users display density dynamically in LWC ?
I keep receiving the below error whenever I attempt to check a hands on challenge. I have logged in and out multiple times and get this error in multiple trailhead boxes.

There was an unhandled exception. Please reference ID: TBRSCDKH. Error: Restforce::UnauthorizedError. Message: INVALID_SESSION_ID: Session expired or invalid