Is it impossible to dynamically instantiate an instance of lightning:menuItem?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
10
down vote

favorite
3












This question is about a potential Lightning platform bug I ran across today. In my search for a resolution I ran across this post from last year that was never answered, that seems to have the identical problem: $A.createComponents() with lightning:buttonMenu and lightning:menuItem



If I'm doing something wrong with my code please let me know. That would certainly be preferred, as the fix will be a lot faster...



The error happens when you click on the menu...you get a popup that says the following:




Assertion Failed!: Descriptor for Config required for registration : undefined




Here is a stripped down reproduction of the bug.



Static Instantiation: Working



Markup:



<aura:application extends="force:slds">

<lightning:buttonMenu aura:id="menu">
<lightning:menuItem />
</lightning:buttonMenu>

</aura:application>


Dynamic Instantiation: Broken



Markup:



<aura:application extends="force:slds">

<aura:handler name="init" value="!this" action="!c.doInit" />

<lightning:buttonMenu aura:id="menu" />

</aura:application>


Controller:



(
doInit : function(component, event, helper)

$A.createComponent('lightning:menuItem', , function(newComponent)

let menu = component.find('menu');

let body = menu.get('v.body');
body.push(newComponent);
menu.set('v.body', body);
);

);


Working Solution



Thanks to great answers and some digging on my own, I've got a working solution that isn't as elegant as I would like but it gets the job done.



Because you can feed ComponentDefRef definitions to a buttonMenu as you instantiate it, you can solve this platform gap by always building your buttonMenu and your menuItem children at the same time. Here is some sample code from the project I was working on this for:



/*
* Create representations of each lightning:buttonMenu that we would like to instantiate
*/
let menusToCreate = ;

// for each column we need to filter
for (let fieldName in filterOptions)
if (filterOptions.hasOwnProperty(fieldName))

let filterData = filterOptions[fieldName],
children = [
attributes:
values:
checked: false,
label: '-- All --',
value: '--all--'

,
componentDef: 'markup://lightning:menuItem'
];

// for each possible filter choice on this column, create a child that represents a lightning:menuItem
filterData.forEach(function (choice)

// this JSON structure is very specific and represents a ComponentDefRef to the Aura framework
children.push(
attributes:
values:
checked: choice.checked,
label: choice.label,
value: choice.value

,
componentDef: 'markup://lightning:menuItem'
);
);

// now that we have all the children, add this menu to our list of dynamic components to build
menusToCreate.push(['lightning:buttonMenu',
'aura:id': fieldName,
'onselect': component.getReference('c.filterChosen'),
'variant': 'bare',
'body': children
]);








share|improve this question






















  • What do you think @kris-gray?
    – Grekker
    Aug 25 at 21:41











  • salesforce.stackexchange.com/questions/228364/…
    – glls
    Aug 25 at 23:50






  • 1




    @glls Sadly, in this case, it's more complicated than that. I've been debugging this thing for the past hour...
    – sfdcfox
    Aug 25 at 23:54










  • :( haven’t been able to check, out camping. But thought your answer could have been helpful
    – glls
    Aug 25 at 23:56
















up vote
10
down vote

favorite
3












This question is about a potential Lightning platform bug I ran across today. In my search for a resolution I ran across this post from last year that was never answered, that seems to have the identical problem: $A.createComponents() with lightning:buttonMenu and lightning:menuItem



If I'm doing something wrong with my code please let me know. That would certainly be preferred, as the fix will be a lot faster...



The error happens when you click on the menu...you get a popup that says the following:




Assertion Failed!: Descriptor for Config required for registration : undefined




Here is a stripped down reproduction of the bug.



Static Instantiation: Working



Markup:



<aura:application extends="force:slds">

<lightning:buttonMenu aura:id="menu">
<lightning:menuItem />
</lightning:buttonMenu>

</aura:application>


Dynamic Instantiation: Broken



Markup:



<aura:application extends="force:slds">

<aura:handler name="init" value="!this" action="!c.doInit" />

<lightning:buttonMenu aura:id="menu" />

</aura:application>


Controller:



(
doInit : function(component, event, helper)

$A.createComponent('lightning:menuItem', , function(newComponent)

let menu = component.find('menu');

let body = menu.get('v.body');
body.push(newComponent);
menu.set('v.body', body);
);

);


Working Solution



Thanks to great answers and some digging on my own, I've got a working solution that isn't as elegant as I would like but it gets the job done.



Because you can feed ComponentDefRef definitions to a buttonMenu as you instantiate it, you can solve this platform gap by always building your buttonMenu and your menuItem children at the same time. Here is some sample code from the project I was working on this for:



/*
* Create representations of each lightning:buttonMenu that we would like to instantiate
*/
let menusToCreate = ;

// for each column we need to filter
for (let fieldName in filterOptions)
if (filterOptions.hasOwnProperty(fieldName))

let filterData = filterOptions[fieldName],
children = [
attributes:
values:
checked: false,
label: '-- All --',
value: '--all--'

,
componentDef: 'markup://lightning:menuItem'
];

// for each possible filter choice on this column, create a child that represents a lightning:menuItem
filterData.forEach(function (choice)

// this JSON structure is very specific and represents a ComponentDefRef to the Aura framework
children.push(
attributes:
values:
checked: choice.checked,
label: choice.label,
value: choice.value

,
componentDef: 'markup://lightning:menuItem'
);
);

// now that we have all the children, add this menu to our list of dynamic components to build
menusToCreate.push(['lightning:buttonMenu',
'aura:id': fieldName,
'onselect': component.getReference('c.filterChosen'),
'variant': 'bare',
'body': children
]);








share|improve this question






















  • What do you think @kris-gray?
    – Grekker
    Aug 25 at 21:41











  • salesforce.stackexchange.com/questions/228364/…
    – glls
    Aug 25 at 23:50






  • 1




    @glls Sadly, in this case, it's more complicated than that. I've been debugging this thing for the past hour...
    – sfdcfox
    Aug 25 at 23:54










  • :( haven’t been able to check, out camping. But thought your answer could have been helpful
    – glls
    Aug 25 at 23:56












up vote
10
down vote

favorite
3









up vote
10
down vote

favorite
3






3





This question is about a potential Lightning platform bug I ran across today. In my search for a resolution I ran across this post from last year that was never answered, that seems to have the identical problem: $A.createComponents() with lightning:buttonMenu and lightning:menuItem



If I'm doing something wrong with my code please let me know. That would certainly be preferred, as the fix will be a lot faster...



The error happens when you click on the menu...you get a popup that says the following:




Assertion Failed!: Descriptor for Config required for registration : undefined




Here is a stripped down reproduction of the bug.



Static Instantiation: Working



Markup:



<aura:application extends="force:slds">

<lightning:buttonMenu aura:id="menu">
<lightning:menuItem />
</lightning:buttonMenu>

</aura:application>


Dynamic Instantiation: Broken



Markup:



<aura:application extends="force:slds">

<aura:handler name="init" value="!this" action="!c.doInit" />

<lightning:buttonMenu aura:id="menu" />

</aura:application>


Controller:



(
doInit : function(component, event, helper)

$A.createComponent('lightning:menuItem', , function(newComponent)

let menu = component.find('menu');

let body = menu.get('v.body');
body.push(newComponent);
menu.set('v.body', body);
);

);


Working Solution



Thanks to great answers and some digging on my own, I've got a working solution that isn't as elegant as I would like but it gets the job done.



Because you can feed ComponentDefRef definitions to a buttonMenu as you instantiate it, you can solve this platform gap by always building your buttonMenu and your menuItem children at the same time. Here is some sample code from the project I was working on this for:



/*
* Create representations of each lightning:buttonMenu that we would like to instantiate
*/
let menusToCreate = ;

// for each column we need to filter
for (let fieldName in filterOptions)
if (filterOptions.hasOwnProperty(fieldName))

let filterData = filterOptions[fieldName],
children = [
attributes:
values:
checked: false,
label: '-- All --',
value: '--all--'

,
componentDef: 'markup://lightning:menuItem'
];

// for each possible filter choice on this column, create a child that represents a lightning:menuItem
filterData.forEach(function (choice)

// this JSON structure is very specific and represents a ComponentDefRef to the Aura framework
children.push(
attributes:
values:
checked: choice.checked,
label: choice.label,
value: choice.value

,
componentDef: 'markup://lightning:menuItem'
);
);

// now that we have all the children, add this menu to our list of dynamic components to build
menusToCreate.push(['lightning:buttonMenu',
'aura:id': fieldName,
'onselect': component.getReference('c.filterChosen'),
'variant': 'bare',
'body': children
]);








share|improve this question














This question is about a potential Lightning platform bug I ran across today. In my search for a resolution I ran across this post from last year that was never answered, that seems to have the identical problem: $A.createComponents() with lightning:buttonMenu and lightning:menuItem



If I'm doing something wrong with my code please let me know. That would certainly be preferred, as the fix will be a lot faster...



The error happens when you click on the menu...you get a popup that says the following:




Assertion Failed!: Descriptor for Config required for registration : undefined




Here is a stripped down reproduction of the bug.



Static Instantiation: Working



Markup:



<aura:application extends="force:slds">

<lightning:buttonMenu aura:id="menu">
<lightning:menuItem />
</lightning:buttonMenu>

</aura:application>


Dynamic Instantiation: Broken



Markup:



<aura:application extends="force:slds">

<aura:handler name="init" value="!this" action="!c.doInit" />

<lightning:buttonMenu aura:id="menu" />

</aura:application>


Controller:



(
doInit : function(component, event, helper)

$A.createComponent('lightning:menuItem', , function(newComponent)

let menu = component.find('menu');

let body = menu.get('v.body');
body.push(newComponent);
menu.set('v.body', body);
);

);


Working Solution



Thanks to great answers and some digging on my own, I've got a working solution that isn't as elegant as I would like but it gets the job done.



Because you can feed ComponentDefRef definitions to a buttonMenu as you instantiate it, you can solve this platform gap by always building your buttonMenu and your menuItem children at the same time. Here is some sample code from the project I was working on this for:



/*
* Create representations of each lightning:buttonMenu that we would like to instantiate
*/
let menusToCreate = ;

// for each column we need to filter
for (let fieldName in filterOptions)
if (filterOptions.hasOwnProperty(fieldName))

let filterData = filterOptions[fieldName],
children = [
attributes:
values:
checked: false,
label: '-- All --',
value: '--all--'

,
componentDef: 'markup://lightning:menuItem'
];

// for each possible filter choice on this column, create a child that represents a lightning:menuItem
filterData.forEach(function (choice)

// this JSON structure is very specific and represents a ComponentDefRef to the Aura framework
children.push(
attributes:
values:
checked: choice.checked,
label: choice.label,
value: choice.value

,
componentDef: 'markup://lightning:menuItem'
);
);

// now that we have all the children, add this menu to our list of dynamic components to build
menusToCreate.push(['lightning:buttonMenu',
'aura:id': fieldName,
'onselect': component.getReference('c.filterChosen'),
'variant': 'bare',
'body': children
]);










share|improve this question













share|improve this question




share|improve this question








edited Aug 28 at 3:54

























asked Aug 25 at 21:40









Grekker

32228




32228











  • What do you think @kris-gray?
    – Grekker
    Aug 25 at 21:41











  • salesforce.stackexchange.com/questions/228364/…
    – glls
    Aug 25 at 23:50






  • 1




    @glls Sadly, in this case, it's more complicated than that. I've been debugging this thing for the past hour...
    – sfdcfox
    Aug 25 at 23:54










  • :( haven’t been able to check, out camping. But thought your answer could have been helpful
    – glls
    Aug 25 at 23:56
















  • What do you think @kris-gray?
    – Grekker
    Aug 25 at 21:41











  • salesforce.stackexchange.com/questions/228364/…
    – glls
    Aug 25 at 23:50






  • 1




    @glls Sadly, in this case, it's more complicated than that. I've been debugging this thing for the past hour...
    – sfdcfox
    Aug 25 at 23:54










  • :( haven’t been able to check, out camping. But thought your answer could have been helpful
    – glls
    Aug 25 at 23:56















What do you think @kris-gray?
– Grekker
Aug 25 at 21:41





What do you think @kris-gray?
– Grekker
Aug 25 at 21:41













salesforce.stackexchange.com/questions/228364/…
– glls
Aug 25 at 23:50




salesforce.stackexchange.com/questions/228364/…
– glls
Aug 25 at 23:50




1




1




@glls Sadly, in this case, it's more complicated than that. I've been debugging this thing for the past hour...
– sfdcfox
Aug 25 at 23:54




@glls Sadly, in this case, it's more complicated than that. I've been debugging this thing for the past hour...
– sfdcfox
Aug 25 at 23:54












:( haven’t been able to check, out camping. But thought your answer could have been helpful
– glls
Aug 25 at 23:56




:( haven’t been able to check, out camping. But thought your answer could have been helpful
– glls
Aug 25 at 23:56










2 Answers
2






active

oldest

votes

















up vote
10
down vote



accepted










Currently no.



The issue is that the body attribute for buttonMenu is of type Aura.ComponentDefRef vs the usual Aura.Component



Because of that, items passed to v.body are expected to be templates to create components vs actual components.



So you can't dynamically create the menuItem instances.



If you explain more why you want to do that, I could explain some workarounds.






share|improve this answer




















  • I was/am trying to build a custom datatable component that allows for column headers offering filter selections with a button menu, and those selection options being dynamic based on the records available to the table. This is for an open source project here: github.com/open-force/grid
    – Grekker
    Aug 28 at 3:40










  • I did come up with a working solution using ComponentDefRef on purpose, which I've been learning more about and trying to use with various levels of success (it's hard not having createComponentFromConfig accessible to us normal people).
    – Grekker
    Aug 28 at 3:40










  • Gotcha. Yea, createComponentFromConfig is on the path to dying, so its good you're making due without it.
    – Kris Gray
    Aug 28 at 4:27






  • 1




    FYI, Developers taking a look at it. Maybe next release we can improve this.
    – Kris Gray
    Aug 28 at 4:28

















up vote
8
down vote













After all this debugging, it appears to be a bug in the framework. Essentially, what's happening is that by the time the menu gets around to rendering the body in changeVisibility, the attribute componentDef on $A.createComponent(s) created lightning:menuItem components happens to be undefined instead of being markup://lightning:menuItem.



This ultimately causes a crash in Aura's $createComponentFromConfig$ method, as it cannot find the definition for this component. The error itself specifically happens on a line that reads something like if(config['descriptor']), which ends up crashing because config is undefined.



Note that I did find you can query the body of an existing menu and manipulate the public attributes of those items, or even remove them from the list. If possible, create a list of as many items as you need in markup, and then use your init method to hide/shuffle/update values as you see fit. I realize it's not ideal, and hopefully this bug will get fixed, but for now, a direct solution appears to be impossible.






share|improve this answer


















  • 2




    You never cease to amaze me.....
    – Eric
    Aug 26 at 3:16










  • @sfdcfox Thanks for digging so deep on this one. I ended up building the menu and the items together at the same time and that works. I'll update my question with some solution code.
    – Grekker
    Aug 28 at 3:38










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f230132%2fis-it-impossible-to-dynamically-instantiate-an-instance-of-lightningmenuitem%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
10
down vote



accepted










Currently no.



The issue is that the body attribute for buttonMenu is of type Aura.ComponentDefRef vs the usual Aura.Component



Because of that, items passed to v.body are expected to be templates to create components vs actual components.



So you can't dynamically create the menuItem instances.



If you explain more why you want to do that, I could explain some workarounds.






share|improve this answer




















  • I was/am trying to build a custom datatable component that allows for column headers offering filter selections with a button menu, and those selection options being dynamic based on the records available to the table. This is for an open source project here: github.com/open-force/grid
    – Grekker
    Aug 28 at 3:40










  • I did come up with a working solution using ComponentDefRef on purpose, which I've been learning more about and trying to use with various levels of success (it's hard not having createComponentFromConfig accessible to us normal people).
    – Grekker
    Aug 28 at 3:40










  • Gotcha. Yea, createComponentFromConfig is on the path to dying, so its good you're making due without it.
    – Kris Gray
    Aug 28 at 4:27






  • 1




    FYI, Developers taking a look at it. Maybe next release we can improve this.
    – Kris Gray
    Aug 28 at 4:28














up vote
10
down vote



accepted










Currently no.



The issue is that the body attribute for buttonMenu is of type Aura.ComponentDefRef vs the usual Aura.Component



Because of that, items passed to v.body are expected to be templates to create components vs actual components.



So you can't dynamically create the menuItem instances.



If you explain more why you want to do that, I could explain some workarounds.






share|improve this answer




















  • I was/am trying to build a custom datatable component that allows for column headers offering filter selections with a button menu, and those selection options being dynamic based on the records available to the table. This is for an open source project here: github.com/open-force/grid
    – Grekker
    Aug 28 at 3:40










  • I did come up with a working solution using ComponentDefRef on purpose, which I've been learning more about and trying to use with various levels of success (it's hard not having createComponentFromConfig accessible to us normal people).
    – Grekker
    Aug 28 at 3:40










  • Gotcha. Yea, createComponentFromConfig is on the path to dying, so its good you're making due without it.
    – Kris Gray
    Aug 28 at 4:27






  • 1




    FYI, Developers taking a look at it. Maybe next release we can improve this.
    – Kris Gray
    Aug 28 at 4:28












up vote
10
down vote



accepted







up vote
10
down vote



accepted






Currently no.



The issue is that the body attribute for buttonMenu is of type Aura.ComponentDefRef vs the usual Aura.Component



Because of that, items passed to v.body are expected to be templates to create components vs actual components.



So you can't dynamically create the menuItem instances.



If you explain more why you want to do that, I could explain some workarounds.






share|improve this answer












Currently no.



The issue is that the body attribute for buttonMenu is of type Aura.ComponentDefRef vs the usual Aura.Component



Because of that, items passed to v.body are expected to be templates to create components vs actual components.



So you can't dynamically create the menuItem instances.



If you explain more why you want to do that, I could explain some workarounds.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 26 at 5:39









Kris Gray

2,8261119




2,8261119











  • I was/am trying to build a custom datatable component that allows for column headers offering filter selections with a button menu, and those selection options being dynamic based on the records available to the table. This is for an open source project here: github.com/open-force/grid
    – Grekker
    Aug 28 at 3:40










  • I did come up with a working solution using ComponentDefRef on purpose, which I've been learning more about and trying to use with various levels of success (it's hard not having createComponentFromConfig accessible to us normal people).
    – Grekker
    Aug 28 at 3:40










  • Gotcha. Yea, createComponentFromConfig is on the path to dying, so its good you're making due without it.
    – Kris Gray
    Aug 28 at 4:27






  • 1




    FYI, Developers taking a look at it. Maybe next release we can improve this.
    – Kris Gray
    Aug 28 at 4:28
















  • I was/am trying to build a custom datatable component that allows for column headers offering filter selections with a button menu, and those selection options being dynamic based on the records available to the table. This is for an open source project here: github.com/open-force/grid
    – Grekker
    Aug 28 at 3:40










  • I did come up with a working solution using ComponentDefRef on purpose, which I've been learning more about and trying to use with various levels of success (it's hard not having createComponentFromConfig accessible to us normal people).
    – Grekker
    Aug 28 at 3:40










  • Gotcha. Yea, createComponentFromConfig is on the path to dying, so its good you're making due without it.
    – Kris Gray
    Aug 28 at 4:27






  • 1




    FYI, Developers taking a look at it. Maybe next release we can improve this.
    – Kris Gray
    Aug 28 at 4:28















I was/am trying to build a custom datatable component that allows for column headers offering filter selections with a button menu, and those selection options being dynamic based on the records available to the table. This is for an open source project here: github.com/open-force/grid
– Grekker
Aug 28 at 3:40




I was/am trying to build a custom datatable component that allows for column headers offering filter selections with a button menu, and those selection options being dynamic based on the records available to the table. This is for an open source project here: github.com/open-force/grid
– Grekker
Aug 28 at 3:40












I did come up with a working solution using ComponentDefRef on purpose, which I've been learning more about and trying to use with various levels of success (it's hard not having createComponentFromConfig accessible to us normal people).
– Grekker
Aug 28 at 3:40




I did come up with a working solution using ComponentDefRef on purpose, which I've been learning more about and trying to use with various levels of success (it's hard not having createComponentFromConfig accessible to us normal people).
– Grekker
Aug 28 at 3:40












Gotcha. Yea, createComponentFromConfig is on the path to dying, so its good you're making due without it.
– Kris Gray
Aug 28 at 4:27




Gotcha. Yea, createComponentFromConfig is on the path to dying, so its good you're making due without it.
– Kris Gray
Aug 28 at 4:27




1




1




FYI, Developers taking a look at it. Maybe next release we can improve this.
– Kris Gray
Aug 28 at 4:28




FYI, Developers taking a look at it. Maybe next release we can improve this.
– Kris Gray
Aug 28 at 4:28












up vote
8
down vote













After all this debugging, it appears to be a bug in the framework. Essentially, what's happening is that by the time the menu gets around to rendering the body in changeVisibility, the attribute componentDef on $A.createComponent(s) created lightning:menuItem components happens to be undefined instead of being markup://lightning:menuItem.



This ultimately causes a crash in Aura's $createComponentFromConfig$ method, as it cannot find the definition for this component. The error itself specifically happens on a line that reads something like if(config['descriptor']), which ends up crashing because config is undefined.



Note that I did find you can query the body of an existing menu and manipulate the public attributes of those items, or even remove them from the list. If possible, create a list of as many items as you need in markup, and then use your init method to hide/shuffle/update values as you see fit. I realize it's not ideal, and hopefully this bug will get fixed, but for now, a direct solution appears to be impossible.






share|improve this answer


















  • 2




    You never cease to amaze me.....
    – Eric
    Aug 26 at 3:16










  • @sfdcfox Thanks for digging so deep on this one. I ended up building the menu and the items together at the same time and that works. I'll update my question with some solution code.
    – Grekker
    Aug 28 at 3:38














up vote
8
down vote













After all this debugging, it appears to be a bug in the framework. Essentially, what's happening is that by the time the menu gets around to rendering the body in changeVisibility, the attribute componentDef on $A.createComponent(s) created lightning:menuItem components happens to be undefined instead of being markup://lightning:menuItem.



This ultimately causes a crash in Aura's $createComponentFromConfig$ method, as it cannot find the definition for this component. The error itself specifically happens on a line that reads something like if(config['descriptor']), which ends up crashing because config is undefined.



Note that I did find you can query the body of an existing menu and manipulate the public attributes of those items, or even remove them from the list. If possible, create a list of as many items as you need in markup, and then use your init method to hide/shuffle/update values as you see fit. I realize it's not ideal, and hopefully this bug will get fixed, but for now, a direct solution appears to be impossible.






share|improve this answer


















  • 2




    You never cease to amaze me.....
    – Eric
    Aug 26 at 3:16










  • @sfdcfox Thanks for digging so deep on this one. I ended up building the menu and the items together at the same time and that works. I'll update my question with some solution code.
    – Grekker
    Aug 28 at 3:38












up vote
8
down vote










up vote
8
down vote









After all this debugging, it appears to be a bug in the framework. Essentially, what's happening is that by the time the menu gets around to rendering the body in changeVisibility, the attribute componentDef on $A.createComponent(s) created lightning:menuItem components happens to be undefined instead of being markup://lightning:menuItem.



This ultimately causes a crash in Aura's $createComponentFromConfig$ method, as it cannot find the definition for this component. The error itself specifically happens on a line that reads something like if(config['descriptor']), which ends up crashing because config is undefined.



Note that I did find you can query the body of an existing menu and manipulate the public attributes of those items, or even remove them from the list. If possible, create a list of as many items as you need in markup, and then use your init method to hide/shuffle/update values as you see fit. I realize it's not ideal, and hopefully this bug will get fixed, but for now, a direct solution appears to be impossible.






share|improve this answer














After all this debugging, it appears to be a bug in the framework. Essentially, what's happening is that by the time the menu gets around to rendering the body in changeVisibility, the attribute componentDef on $A.createComponent(s) created lightning:menuItem components happens to be undefined instead of being markup://lightning:menuItem.



This ultimately causes a crash in Aura's $createComponentFromConfig$ method, as it cannot find the definition for this component. The error itself specifically happens on a line that reads something like if(config['descriptor']), which ends up crashing because config is undefined.



Note that I did find you can query the body of an existing menu and manipulate the public attributes of those items, or even remove them from the list. If possible, create a list of as many items as you need in markup, and then use your init method to hide/shuffle/update values as you see fit. I realize it's not ideal, and hopefully this bug will get fixed, but for now, a direct solution appears to be impossible.







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 26 at 0:56

























answered Aug 26 at 0:49









sfdcfox

225k10171385




225k10171385







  • 2




    You never cease to amaze me.....
    – Eric
    Aug 26 at 3:16










  • @sfdcfox Thanks for digging so deep on this one. I ended up building the menu and the items together at the same time and that works. I'll update my question with some solution code.
    – Grekker
    Aug 28 at 3:38












  • 2




    You never cease to amaze me.....
    – Eric
    Aug 26 at 3:16










  • @sfdcfox Thanks for digging so deep on this one. I ended up building the menu and the items together at the same time and that works. I'll update my question with some solution code.
    – Grekker
    Aug 28 at 3:38







2




2




You never cease to amaze me.....
– Eric
Aug 26 at 3:16




You never cease to amaze me.....
– Eric
Aug 26 at 3:16












@sfdcfox Thanks for digging so deep on this one. I ended up building the menu and the items together at the same time and that works. I'll update my question with some solution code.
– Grekker
Aug 28 at 3:38




@sfdcfox Thanks for digging so deep on this one. I ended up building the menu and the items together at the same time and that works. I'll update my question with some solution code.
– Grekker
Aug 28 at 3:38

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f230132%2fis-it-impossible-to-dynamically-instantiate-an-instance-of-lightningmenuitem%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

What does second last employer means? [closed]

One-line joke