I have a lightning-record-form
in a modal dialog defined as follows:
<div role="dialog"
tabindex="-1"
data-id="editDialog"
class='slds-modal'>
<div class="slds-modal__container">
<header class="slds-modal__header">
<h2 class="slds-modal__title">Edit Lead</h2>
</header>
<div class="slds-modal__content
slds-var-p-around_medium">
<lightning-record-form record-id={recordId}
object-api-name="Lead__c"
fields={fields}
columns="2"
mode="edit"
onsuccess={handleSuccess}
oncancel={handleCancel}>
</lightning-record-form>
</div>
</div>
</div>
It works perfectly the first time, showing a modal dialog with the fields ready to edit.
But regardless of whether I save or cancel the dialog, the second time it appears, it shows up in view mode. Users can edit, but they have to click the pencil button. Everything does appear to work after that, however.
The handlers for the modal simply remove the appropriate classes and if a save has occurred, update the record.
refresh() {
refreshApex(this._refresh);
}
get dialog() {
return this.template.querySelector('[data-id="editDialog"]');
}
get backdrop() {
return this.template.querySelector('[data-id="dialogBack"]');
}
closeDialog() {
this.dialog.classList.remove('slds-fade-in-open');
this.backdrop.classList.remove('slds-backdrop_open');
}
handleCancel() {
this.closeDialog();
}
handleSuccess() {
this.closeDialog();
this.refresh();
}
How do I get it to show up in edit mode every time?
record-edit-form
instead.if:true
tag, so whenever the record id changes it will completely rerender itself.datatable
's row actions? Is it possible to "unmount" the dialog during the close phase and "mount" it when I want it open? As you can probably tell, the dialog is shown by editing the class list.