Using core-dropdown to select multiple items

2019-05-31 02:23发布

问题:

When a user clicks in a report button, they should be able to select one or more types of issues. I'm trying something like this:

<core-icon-button icon="report" on-tap="{{ openDropdown }}">
   <core-dropdown>
      <core-selector valueattr="label" multi>
         <core-item label="Type 1"></core-item>
         <core-item label="Type 2"></core-item>
         <core-item label="Type 3"></core-item>
      </core-selector>
      <button on-tap="{{ reportIssue }}">Report</button>
   </core-dropdown>
</core-icon-button>

But when I select any item the dropdown closes. My expected behaviour would be to close the dropdown only after reportIssue is called.

Is what I'm trying to do possible with core-dropdown (or any other core element) or should I build a custom element for this? Feels like a waste since almost all the behaviour I need is provided already by core-dropdown.

EDIT: The problem seems to be that I had core-dropdown inside core-icon-button. After I changed that everything works as expected. :)

回答1:

Try closeAttribute or closeSelector. See core-overlay documentation