Questions tagged [lightning-web-components]

This tag is for questions related to JavaScript, CSS, or Markup when used in the Lightning Web Component (LWC) programming model, or for questions of interoperability between LWC and the original Aura-based lightning components.

1,756 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
2answers
497 views

Event propagation with bubble true in LWC

I'm trying learn event propagation in LWC. As per the documentation it says {bubble: true, composed: false} means the event does not cross the shadow boundary, but it bubbles up the shadow boundary. I ...
6
votes
2answers
1k views

How to dynamically import a module in lwc

I am trying to import modules dynamically in my LWC component. While pushing the change I get a strange error LWC1509: This experimental syntax requires enabling the parser plugin: 'dynamicImport' ...
6
votes
0answers
624 views

How to get a PageReference from Site.login(username, password, url) in an Apex Test

When I run this code from within a LWC controller: ApexPages.PageReference pageRef = Site.login(username, password, url); It returns a valid PageReference instance. But when I test the code in a ...
6
votes
1answer
638 views

UI API within LWC as an ISV. What should be the approach when wire adapters are not feasible?

I have a lightning web component that needs to call UI API. I can't use the LWC wired adapters because the 'getRecordUi' does not take the "childRelationships" parameters like the 'record-ui' endpoint ...
6
votes
0answers
675 views

External Objects not supported in Force.com sites

(Edit: all of this is happening only in a Force.com site. The Lightning Web Component is not the source of the problem) I'm trying to query an External Object inside @AuraEnabled method, but I'm ...
6
votes
0answers
779 views

Getting Organization Id in a Lightning Web Component?

I found you can get the current user id like this: import id from '@salesforce/user/Id'; I have a really simple component where all I need are the User Id and the current Org Id. I haven't been able ...
6
votes
0answers
1k views

Does ui:scrollerWrapper have an equivalent in Lightning Web Components?

Using slds-scrollable class in Lightning Web Component works in desktop browser but not on Salesforce Mobile app. For Aura components you would use the ui:scrollerWrapper to accomplish this. I've ...
5
votes
0answers
165 views

How to disable lightning locker service by default in community

I have an lwc component to display charts using chartjs library in the community. The component was working perfectly in internal salesforce but the chartjs library failed to load in the community. By ...
5
votes
0answers
133 views

Can I get all existing Pages for a Community using Apex?

I would like to create a custom component to use in Experience Builder, and this component will allow a configurable navigation to another page. I would like to use a dynamic picklist with Apex to get ...
5
votes
0answers
185 views

Declaratively mocking a custom LWC in a single unit test

The approaches suggested of using jestconfig module mapper or the mocks folder work well if you have a single mock per component you are testing, but not if you have to build how your parent component ...
5
votes
1answer
145 views

Why are SObject fields returned to an LWC via @AuraEnabled Apex immutable?

I get this error: TypeError: 'set' on proxy: trap returned falsish for property 'cvcp__ReturnToWorkType__c' when attempting to set a value via JavaScript inside an LWC (Lightning Web Component): sob....
5
votes
0answers
267 views

Neither forceCommunity:routeChange or aura:locationChange cannot detect the URL change with history.replaceState

We have a use case where a lightning component built in LWC, should trigger a URL change. We're handling that with the history.replaceState method(note that we encountered the same problem with ...
5
votes
2answers
2k views

You can’t remove the following public properties because the component is part of a managed package

I am trying to push a JS file in a LWC Component and am unable to do so with this error lwc/boatMap/boatMap.js-meta.xml: You can’t remove the following public properties: boatId, because the component ...
5
votes
1answer
1k views

Multi language support in community built using LWC (Migration from Visualforce to LWC)

We have an Identity community which supports more than 50 languages built using visualforce pages. We would like to migrate the community to LWC. For that, main issue we are facing is the language ...
5
votes
1answer
3k views

Setting a max height for datatable in LWC?

I know when you specify a div with a height around your datatable you get a nice scrollable table: <div style="height: 300px:"> <lightning-datatable various-params></lightning-...
5
votes
0answers
333 views

Architecture decision: use canvas app or lightning out?

Suppose we need to develop an app which can be used both inside Salesforce and in another web site. And definitely we don't want to duplicate the code. So basically there are two options here: ...
5
votes
0answers
925 views

My LWC test is not displaying code coverage

I have configured jest for Lightning web component test. My tests are running and passing but code coverage not displaying into output. Following is package.json file: - { "name": "my-...
5
votes
0answers
964 views

lightning-record-edit-form component not being record-type aware

I wrote a lightning web component that includes a lightning-record-edit-form component. We are using PersonAccounts here and there are 2 RecordTypes on PersonAccount as well. The Type__c field is a ...
5
votes
0answers
816 views

Lightning Web Components: Set scroll position on lightning-datatable based on 'key' field value

We are looking to auto-scroll the user to a specific point in a lightning-datatablewhen a button is clicked. Assuming we referenced the key-field attribute data-row-key-value in the dom then in HTML ...
5
votes
0answers
2k views

Error while loading a js as static resource in lightning Web component

I have a static resource name KendoUI, which is a javascript and is public. In my application, I have this : import { LightningElement } from 'lwc'; import { loadScript, loadStyle } from 'lightning/...
5
votes
2answers
4k views

Property value is not refreshing on Template when its Non-Primitive type

I am trying to update value of property in Parent Component which is pass in Child component. But after update value is reflecting in child component'c class (.js) but not in view (.html) Is it ...
4
votes
0answers
54 views

LWC OSS: How to set properties of components imported dynamically?

I am trying create components dynamically with the help of lwc:dynamic directive in LWC OSS. I am able to create those comments dynamically, but not able to set the properties to them. For each ...
4
votes
0answers
108 views

LWC Typescript this parameter type

defineProperties(Element.prototype, { querySelector: { value: querySelectorPatched, writable: true, enumerable: true, configurable: true, }, ...
4
votes
0answers
100 views

can showToast be utilized in LWR site (Experience Cloud)?

According to this official documentation the platform-show-toast-event component/event is unsupported in LWR site. According to this official sample LWR site a showToast event is utilized (see line 76 ...
4
votes
0answers
139 views

How to correctly enable Type checking in VSCode for LWC?

I wonder how to sucessfully configure type checking in VSCode for LWC. VSCode has JS/TS compiler that support type checking when we set jsconfig.json with compilerOptions like below: "...
4
votes
0answers
39 views

How to handle Platform Event while UI is being rerendered?

Use case: We have Digital Experience (i.e Community) where at first we perform the action and after it, we redirect to a new page. This action also publishes Platform Event (Notification) which should ...
4
votes
1answer
153 views

How to replicate the functionality of delivered "File Engagement" lwc card?

In our org we have a need to programmatically replicate the functionality of delivered “File Engagement” component/card. Here is a snapshot from our live org, on a ContentDocument view page: Since ...
4
votes
0answers
388 views

Lightning record page printable view or PDF

I need to create a printable view (or PDF) of a record's Lightning Page (think "tear sheet") that includes a compact "details" section, compact related list tables, and a custom ...
4
votes
0answers
275 views

Showing custom notification in Community | Theme : Build your own || Custom apex notifications

I want to show custom notification through apex in the community. Community is having custom theme(all lightning components). I know how to trigger apex custom notifications for the internal users. ...
4
votes
0answers
54 views

Are fully custom SLDS themes possible in communities?

Bootstrap has a "themes" mechanism where a HTML page using the Bootstrap class names can be presented using many different colour schemes, fonts, spacing etc. For example: or and it is ...
4
votes
0answers
47 views

When will ::part be available and will header cells in lightning-datatable be allowed for overriding?

I am specifically asking about the answer provided here We have many projects which have community implementations. As it is well known that communities tend to have their own themes and styles, the ...
4
votes
0answers
228 views

Lightning Map(Lwc) is not working on playground and documentation demo

Lightning map demo from the LWC documentations is not working. I am getting the below error. Unable to resolve forcehelp/linkToNonSalesforceResource from api/runtime/lwc-components/1.5.6-alpha/...
4
votes
0answers
95 views

Org Cache Behaving differently in Sandbox

I'm using org cache to store the results of a call to the google maps geocode api. Just noticed, the caching doesn't seem to work in a Sandbox. You can see how I'm storing/accessing here: public ...
4
votes
1answer
1k views

Google Analytics Event Tracking in Community using LWC

I'd like to use Google Analytics Event Tracking inside a Community in LWC We have Google Analytics configured in Builder > Settings > Advanced > Google Analytics The documentation says to ...
4
votes
0answers
774 views

Detecting change on Record in Lightning Web Component withing Communities

I am looking for a solution to a basic scenario: A User in a Community submits an Opportunity, this Opportunity is enriched with data synchronously upon insert and asynchronously through ...
4
votes
0answers
299 views

Why can't I skip LWC namespaces in namesspaced scratch org

I have an LWC component as part of a managed package. To support Classic its also embedded inside VF page using a Lightning App(Aura): <apex:page standardcontroller="Account"> <apex:...
4
votes
0answers
227 views

TargetConfig Property cannot contain JSON-like string?

STR Create an LWC Give it a property in its target config of type "string" Add the LWC to a lightning record page, and insert { } into the property Save (and activate) the page Load a record which ...
4
votes
0answers
483 views

LWC @wire order of execution not working for ie11

I have implemented a lightning web component (lwc) that shows a dependent picklist field To load a dependent picklist in lwc I use @wire with getPicklistValues and because getPicklistValues requires ...
4
votes
1answer
1k views

lwc getFieldValue from a custom external object

I am creating a LWC that handles data from an external object. I have access to the recordId through @api recordId;, but I need to get the externalId from this object as well. Currently, I have call ...
4
votes
0answers
4k views

NoErrorObjectAvailable Script error. Salesforce LWC

[NoErrorObjectAvailable] Script error. We trying to update the record data dynamically. we are sending the data from child to parent. We are trying to update the JSON object based on dynamically key ...
4
votes
2answers
2k views

Salesforce: Drag & Drop not working in lightning web components or drop events are not triggering

I have a Lightning web component to drag one div into other dropzones (div). But the ondrop & ondragover events are not firing. Here is my code <template> <div class="draggable" ...
4
votes
2answers
1k views

How to show custom error message in lightning-file-upload in lightning web component

I need to show a custom error message in lightning-file-upload when we tried to upload the unacceptable format of the file. <lightning-file-upload label="Attach receipt" ...
4
votes
0answers
468 views

Warning when setting input value in test

I'm writing unit tests for LWC using lwc-jest but when I try to follow the pattern documented in the Basic Lightning Component section of this documentation https://developer.salesforce.com/docs/...
4
votes
1answer
1k views

Lightning Radio/Checkbox option level helptext

Just wondering if it is possible in LWC to provide help text at a option level for radio-group or checkbox-group? We are wanting to provide further details about why a user might select each option. ...
4
votes
2answers
379 views

SFDX CLI initial deployment failure: chicken and egg?

Using the latest sfdx CLI version (sfdx-cli/7.22.0-de5c6ecff8 win32-x64 node-v10.15.3) I am now facing a problem with initial deployment (force:source:push) to a scratch org. Scenario: We have an ...
4
votes
0answers
407 views

Jest Unit test an event that dispatches inside XMLHTTPRequest (XHR)

How do I test an event that does an XHR request and dispatches an event? I managed to install the dependencies to mock the xhr using https://github.com/jameslnewell/xhr-mock/tree/master/packages/xhr-...
4
votes
0answers
878 views

Using Javascript window.confirm() in Lightning Experience

We are using window.confirm() in the JS parts of Lightning Aura Components and embedded Visualforce pages (iframed). This worked just fine for several years. Yesterday I noticed that in both use ...
4
votes
0answers
2k views

Unable to resolve custom label in lightning web component

With reference to the document Access Labels for lwc, I created few custom labels and used them in my web component; most of the labels were unable to resolve. I don't understand why exactly. To ...
4
votes
1answer
2k views

Is there a way to use a private custom lwc Component (isExposed=false) in a flexipage that will be deployed in a managed package?

We are an ISV partner and are working on a managed package that we will release soon. We are mostly using LWC components and found that if we try to include one of our custom LWC component into a ...
4
votes
0answers
631 views

LWC: Add a region in custom community theme

I would like to add a region in my custom community theme. For now I am only able to add my LWC components in the body area and would like to know how I can declare regions in my theme to accept LWC (...

1
2 3 4 5
36