Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when binding value is modified in parent components init handler #83

Open
sankaran1984 opened this issue Mar 7, 2022 · 2 comments
Assignees
Labels
active This issue is currently active investigating investigating waiting on response waiting on response

Comments

@sankaran1984
Copy link

sankaran1984 commented Mar 7, 2022

Describe the bug
I am seeing an error when the binding value is modified in the parent component's init handler.

To Reproduce

  1. create a test lightning App

Testapp.app

<aura:application extends="force:slds">
	<aura:attribute name="buttonLabel" type="String" default="Neutral"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.initHandler}"/>    

    <!-- create following button component using Force-DI -->
    <!-- <lightning:button label="Neutral"></lightning:button> -->   
    <c:di_injector bindingName="lc_button">
        <c:di_injectorAttribute name="label" value="{!v.buttonLabel}"/>
    </c:di_injector>
</aura:application>

TestappController.js

({
	initHandler : function(cmp, evt, helper) {
		cmp.set('v.buttonLabel', 'brand');
	}
})
  1. create custom metadata
    di_Binding.lc_button
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <label>lc_button Binding</label>
    <protected>false</protected>
    <values>
        <field>BindingObjectAlternate__c</field>
        <value xsi:nil="true"/>
    </values>
    <values>
        <field>BindingObject__c</field>
        <value xsi:nil="true"/>
    </values>
    <values>
        <field>BindingSequence__c</field>
        <value xsi:nil="true"/>
    </values>
    <values>
        <field>To__c</field>
        <value xsi:type="xsd:string">lightning:button</value>
    </values>
    <values>
        <field>Type__c</field>
        <value xsi:type="xsd:string">LightningComponent</value>
    </values>
</CustomMetadata>

Steps to reproduce the behavior:

  1. Create a scratch org & deploy force-di package
  2. create lightning app & custom metadata as mentioned
  3. preview the app - /c/Testapp.app

Expected behavior
No error expected.

Screenshots and text of error observed
image

Version
Did you try to reproduce the problem against the latest force-di code? yes

@ImJohnMDaniel ImJohnMDaniel self-assigned this Mar 8, 2022
@ImJohnMDaniel ImJohnMDaniel added active This issue is currently active investigating investigating labels Mar 8, 2022
@ImJohnMDaniel
Copy link
Collaborator

@sankaran1984, thanks for reporting this. While I appreciate the narrative above, it would be helpful if you can prepare a sample project with all source code you are describing above that we can reference. My concern is that in attempting to reproduce this, we may inadvertently create something different and go down a wrong path. Thanks for the help.

@ImJohnMDaniel ImJohnMDaniel added the waiting on response waiting on response label Mar 8, 2022
@sankaran1984
Copy link
Author

sankaran1984 commented Mar 8, 2022

Thanks @ImJohnMDaniel Here's my local project in my own dev org where I reproduced this issue,

https://github.com/sankaran1984/MyOrg/tree/main/force-di-issue-83

let me know if you need more information.

Resolution
It may not be the best solution, but I manage to fix it in our local repo until this gets properly fixed. Here's my quick fix,
line 105 & 112

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
active This issue is currently active investigating investigating waiting on response waiting on response
Projects
None yet
Development

No branches or pull requests

2 participants