Skip to main content
Group

Lightning Components Development

This group is for customers and partners who are using the Lightning Components. It's a forum for customers to provide feedback, requirements and share ideas. Customers may also leverage this group to collaborate with each other on best practices. This group is maintained and moderated by a salesforce.com employee(s). The content received in this group falls under the official Safe Harbor. Please also see our official Salesforce Customer Community Terms of Use

I have noticed that the modal popup shows on top of the page rather than at the center of the user screen. Is there a way we can position the modal based on the user screen? Also, I noticed that the background is not locked as it happens on the desktop, I am still able to click on the background page and make selections.

5 answers
  1. Apr 30, 12:30 PM

    Hi @rajesh madhabakthula

     

    Js:  

    connectedCallback() {

     

            if (FORM_FACTOR == "Large") {

                this.modelSecionStyle = 'slds-modal slds-fade-in-open slds-backdrop slds-backdrop_open';

            } else if (FORM_FACTOR == "Small") {

                this.modelSecionStyle = 'slds-fade-in-open slds-backdrop slds-backdrop_open mobileCenter';

            }

     

        } 

    -------------- 

    css: 

    .mobileCenter {

        position: fixed;

        top: 0;

        left: 0;

        width: 100%;

        height: 2000PX;

        z-index: 9999;

        display: flex;

        align-items: center;

        justify-content: center;

        background: rgba(0, 0, 0, 0.5);

        padding: 16px;

        box-sizing: border-box;

    }

     

     

    .mobileCenter .slds-modal__container {

        top: 10px;

        left: 0;

        width: 100%;

        height: 1000PX;

        border-radius: 16px;

        overflow: hidden;

        display: flex;

        flex-direction: column;

        background: white;

        margin: 0;

        box-shadow: none;

    }

     

    .mobileCenter .slds-modal__header {

        border-radius: 16px 16px 0 0;

        padding: 20px 16px;

        text-align: center;

        border-bottom: 1px solid ;

        flex-shrink: 0;

    }

     

    .mobileCenter .slds-modal__content {

        overflow-y: auto;

        flex: 1;

        padding: 16px;

        max-height: none;

        -webkit-overflow-scrolling: touch;

    }

     

    .mobileCenter .slds-modal__footer {

        position: sticky;

        bottom: 0;

        background: white;

        border-top: 1px solid ;

        padding: 12px 16px;

        display: flex;

        justify-content: flex-end;

        gap: 12px;

        flex-shrink: 0;

        border-radius: 0 0 16px 16px;

    }

0/9000

Hi team, 

 

We have requirement to show only the record in view mode in the community site. We are having restriction to make all field readonly in layout hence we have to go with customization where we created lwc component with lightning outputfield as referenced below.

Can we apply styling to lightning-outputfield

But this looks very basic not appealing to end user. Could you please guide if we can apply and styling to this ? What would be best approach here. 

 

@Salesforce Certified Professionals

2 answers
0/9000

Hi @Lightning Components Development I am facing a critical issue where I can not force the lightning input date field to 100% on iphone. I am using it in the flow. I tried any CSS possible solution but that did not work. Let me know If anyone have any clue about that:\ Can not force 100% width to the lightning input date field on iphone

 

 

 

#Mobile

2 answers
0/9000

I recently created custom email component in LWC, this looked fine, but recently I received feedback that the templates which were sent from my component do not look the same as the templates they created.

So what I did is: I icluded an option to choose an Email template which current user would like to inject into lightning-input-rich-text, what I did is a renderStoredEmailTemplate().getHtmlBody() also tried renderEmailTemplate().getMergedBody() in controller of the component, so it basically retrieved proper HTML body, inspected it, checked on some online html editor, all looked the same, no issues so far. Then I passed that value to lightning-input-rich-text (the same issue in Aura), inspected the value of this field, these looked totaly different, read bit more documentation: "Pasting text enclosed in div and span tags convert those tags to p tags", ok cool but it looks like the behaviour is not as expected, also having triple spans received from HTMLValue in template made it much worse, issues I encounter so far:

- <br /> tags are also changed to p tags, so afterwards it gave me double breaks instead of single

 

- I had a span before <ul>, for some reason richTextField included it inside <ul>

 

- If I had a wrapper span and breaks inside, child spans were getting on a separate line and the styling got completelly different after break

The only option I can see right now is to show lightning-formatted-rich-text instead, but then users will not have access to modify the body of email, only to choose a template, but leaving as it is also makes this component worthless since this will not look good for our customers.

I am expecting that once I retrieve HTML body from email template and pass it to the lightning-input-rich-text I will receive the same result. Did anybody encounter the same? Cannot see anything regarding this in SF issues, nor I can find a workaround for it.

1 answer
0/9000

We have performance issues on our orgs when turning on LWS. 

It is mostly seen on larger LWC components with a lot of logic. 

I belive this is due to js objects/arrays being wrapper in LWS proxy wrappers. 

I know SF documentation suggests using copies to mitigate this issue: 

const objectCopy = JSON.parse(JSON.stringify(object)); 

 

My question is, are there plans to fix this on LWS side? If yes, then when? Or will this workaround be a permanent required solution to the performance problem?

1 answer
  1. Aug 4, 2025, 7:24 AM

    My guess would be - There won't be any plans to fixing this issue. Given this is not an issue that can be resolved at all. LWS do not prefer passing attributes from one cmp to another in large number. And if this hierarchy is bigger then it becomes much more impactful as well. "Proxifying" objects for security has a cost, and this is the cost. And issue can only be resolved if platform don't Proxy it, which is not possible. 

     

    The solution however is to break the cmps to multiple. and don't pass attributes data through api params. Try to limit that as much as possible.

0/9000

Hi Guys,

Can you please suggest how can we print pdf from lwc component?

I tried window.print() which gives whole page, we only want contents from our lwc component. 

 

#LWC Development

#Download Pdf

6 answers
  1. Jul 17, 2024, 12:38 PM

    Hello community! 

    I had similar task and was able to complete it using just lwc! 

     

    For that I had to create the following js method:

     

    handlePrintClick () {

    let printableElement = this.template.querySelector('.print-section');

    if (printableElement) {

    let clone = printableElement.cloneNode(true);

    let printWindow = window.open('', '_blank');

    if (printWindow) {

    printWindow.document.body.appendChild(clone);

    let style = printWindow.document.createElement('style');

    style.textContent = `

    @page {

    size: auto; /* auto is the initial value */

    margin: 0mm; /* this affects the margin in the printer settings */

    }

    @media print {

    body {

    margin: 0;

    padding: 0;

    }

    .no-print {

    display: none;

    }

    }

    `;

    printWindow.document.head.appendChild(style);

    printWindow.focus();

    printWindow.print();

    printWindow.close();

    } else {

    console.error('Failed to open print window');

    }

    } else {

    console.error('Printable element not found');

    }

    }

    and you need to update the content of html with css class to the place which you wanted to print (I had lots of inner data, parent and childs)

     

    <div class="print-section">

    Data which should be printed

    </div>

    Note: In my case I had all css values in the same html file (not a separate css, I used style tag) 

0/9000

Hi. We are trying to turn on LWS on our production org, but we are encountering issue after issue. 

We already refactored some of our custom LWC components, so that they perform better with LWS (mostly removing proxy wrapper from data retrieved using Apex). 

 

Now we have issue with yet another component. It is a big one. 

There is a lot of data rendered on the component and user has the ability to edit it. 

I already made copy of the data using JSON.parse(JSON.stringify()) but it did not help. 

On top of that, we are using barcodeScanner which is functionality provided by SF (mobileCapabilities). 

Without LWS code scanning takes around 1 second to scan. With LWS it can take almost 10 times that! 

And we do not have ability to refactor that method. 

 

So I have a couple of questions: 

- are there plans to fix barcodeScanner functionality with LWS enabled? 

- are there any other ways to help with LWS performance on large LWC components? Besides mentioned above, avoiding sets and maps etc. 

- this LWC component is used in flow and that flow is launched from LWC on app page. Could this also slow it down? (although parameters passed down from flow are only strings, not objects or arrays)

5 answers
  1. Jul 3, 2025, 2:40 PM

    @Gary Chang

     

     

    I'm not able to do that. The scanner does not work on desktop and I cannot debug component on mobile (SF app is not detected when using USB debugger with Chrome Inspect Tool). I tracked timing with JS code only.

0/9000

We have a 

handleSubscribe() function called from connectedCallback() function. handleSubscribe() has messageCallback function. When connectedCallback() is executed and handleSubscribe() function is entered we are able to access this.label

 object(which has properties coming from Custom Labels) and their property can be logged.  

 

When the 

messageCallback is executed and the logic within is run there we are not able to retrieve this.label values. The this.label is undefined. 

 

connectedCallback(){

this.isSpinnerLoading = true;

this.handleSubscribe();

checkApplicationStatus({hostApplicationRecordId: this.recordId})

.then(result=>{

if(result && result.validApplicationStatus === true){

this.invalidHostApplicationStatus = false;

if(result.associatedWithGoogleMeta){

this.isAssociatedWithGoogleMeta = true;

generateParticipantLinkOnStart({hostApplicationRecordId: this.recordId})

.then(result=>{})

.catch(error=>{

console.error(error);

})

.finally(()=>{

//this.isSpinnerLoading = false; //this should happen via the platform event

})

}

}

})

.catch(error=>{

console.error(error);

})

}

handleSubscribe() {

// Callback invoked whenever a new event message is received

const self = this;

const messageCallback = function (response) {

var obj = JSON.parse(JSON.stringify(response));

let objData = obj.data.payload;

self.disableSendButton = !objData.DS_Links_Generated__c;

if(self.isSpinnerLoading){

self.isSpinnerLoading = false;

}

//toast links generated message

const evt = new ShowToastEvent({ //get user to select an option first

title: 'Success',

message: this.labels.dsGeneratedSuccessMessage,

variant: 'success',

});

this.dispatchEvent(evt);

};

// Invoke subscribe method of empApi. Pass reference to messageCallback

subscribe(this.channelName, -1, messageCallback).then(response => {

// Response contains the subscription information on subscribe call

this.subscription = response;

});

}

 

 

this.label is undefined when messageCallback function runs.

 

 

Could you please let me know what is the problem here? How can we retain the value for this.label when messageCallback is executed. What would be the right approach to retain the value / how can we still able to access the value?

 

Please help!!! 

  

@Salesforce Certified Professionals@* Salesforce Developers *@Lightning Components Development

5 answers
0/9000

Hi I need help to upload the font awesome icons and use them in LWC. Please guide me. Thanks

3 answers
  1. Apr 21, 2025, 7:17 AM

    Hi @Muhammad Naveed Nawab

     

     

    Please check this once 

    HTML File:-

    <template>

    <i class="fa-solid fa-bars"></i>

    </template>

    JavaScript File:-

    import { LightningElement } from 'lwc';

    import { loadStyle } from 'lightning/platformResourceLoader';

    import Fontawesome from '@salesforce/resourceUrl/BootstapCDN';

    export default class PortfolioFooter extends LightningElement {

    renderedCallback() {

    Promise.all([

    loadStyle(this, Fontawesome + '/css/all.css')

    ]).then(() => {

    console.log( 'Files loaded' );

    })

    .catch(error => {

    console.log( error.body.message );

    });

    }

    }

    Reference link:-  

    https://salesforce.stackexchange.com/questions/309305/how-to-make-font-awesome-icons-work-on-lightning-web-components

      

     

    Hope this helps  

    Thanks 

     

0/9000
0/9000