3

On a standard page in a Napili-based Community a want to render a <lightning:select>. As a starter, I just want to have one simple empty option.

The html-way it works just fine:

<select value="" >
    <option text="" value="" label="-" />
</select>

But doing the very same with <lightning:select> fails

<lightning:select aura:id="myPicklist">
    <option text="" value="" label="-" />
</lightning:select>

I get only this error and the entire page does not render anymore. The page output collapses to this

Invalid Page

In the browser console, I found this as WARNING:

aura_proddebug.js:24582 WARNING: An internal server error has occurred Error ID: 1403404160-155558 (-1306587905) in aura_proddebug.js:24582

Why this is happening? Is <lightning:select> not usable in Communities at all? Where this is documented? I've checked the docs https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_select.htm but could not find any reason why it shouldn't work.

Why we get only this error Id and nothing readable? In the console, why this is only a WARNING and not a ERROR?

Do I have to prepare myself and expect other member of the lightning namespace failing in a similar manner?

Full Source-Code

Just toggle the commented lines to see the issue:

<aura:component implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" >
    TEST
    <select value="" >
        <option text="" value="" label="-" />
    </select>
    <!--<lightning:select aura:id="elfSelectProducts" class="elfPicklist elfSelectProducts">-->
    <!--    <option text="" value="" label="-" />-->
    <!--</lightning:select>-->
</aura:component>

2 Answers 2

8

You are not specifying the required attributes in your component as stated in the documentation:

Attribute Name ----- Attribute Type --------- Required?

label -------------- String ----------------------- Yes

name -------------- String ----------------------- Yes

<lightning:select name="selectItem" label="Select an item">
    ...options...
    </lightning:select>
8
  • 2
    Yup. this got me more times than I can count. Seems simply throwing "Missing required attribute: Name" would have been much more useful
    – Eric
    Commented Sep 25, 2017 at 19:30
  • Error ID: 1403404160-155558 (-1306587905) is much more intuitive imo
    – glls
    Commented Sep 25, 2017 at 19:35
  • 1
    In my best Sheldon voice "Sarcasm?"
    – Eric
    Commented Sep 25, 2017 at 19:36
  • :joy: hehe, you got me there =P
    – glls
    Commented Sep 25, 2017 at 19:39
  • 3
    @UweHeim - Sadly this will not be the last or only inconsistency you will find between LEX, Community, ltng:out etc. There are time sinks all over the place and workarounds galore. It will get better though
    – Eric
    Commented Sep 25, 2017 at 20:36
0

Adding on to @glls answer, even if you use [variant="label-hidden"] you must still specify [label=""] as it is one of the required attributes and yes, the < label > tag will still render in the HTML just with nothing inside of it. That was a fun one to track down.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .