Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,29 @@ <h4>You can style a paper-dropdown-menu using custom properties</h4>
</paper-dropdown-menu-light>
</template>
</demo-snippet>

<h4>This is a multiselect paper-dropdown-menu</h4>
<demo-snippet class="centered-demo">
<template>
<paper-dropdown-menu label="Dinosaurs" ignore-select>
<paper-listbox slot="dropdown-content" class="dropdown-content" multi>
<paper-item>allosaurus</paper-item>
<paper-item>brontosaurus</paper-item>
<paper-item>carcharodontosaurus</paper-item>
<paper-item>diplodocus</paper-item>
</paper-listbox>
</paper-dropdown-menu>

<paper-dropdown-menu-light label="Dinosaurs (light)" ignore-select>
<paper-listbox slot="dropdown-content" class="dropdown-content" multi>
<paper-item>allosaurus</paper-item>
<paper-item>brontosaurus</paper-item>
<paper-item>carcharodontosaurus</paper-item>
<paper-item>diplodocus</paper-item>
</paper-listbox>
</paper-dropdown-menu-light>
</template>
</demo-snippet>
</div>

<script>
Expand Down
13 changes: 11 additions & 2 deletions paper-dropdown-menu-light.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@
on-iron-select="_onIronSelect"
on-iron-deselect="_onIronDeselect"
opened="{{opened}}"
close-on-activate
allow-outside-scroll="[[allowOutsideScroll]]">
allow-outside-scroll="[[allowOutsideScroll]]"
ignore-select="[[ignoreSelect]]">
<!-- support hybrid mode: user might be using paper-menu-button 1.x which distributes via <content> -->
<div class="dropdown-trigger" slot="dropdown-trigger">
<label class$="[[_computeLabelClass(noLabelFloat,alwaysFloatLabel,hasContent)]]">
Expand Down Expand Up @@ -443,6 +443,15 @@
hasContent: {
type: Boolean,
readOnly: true
},

/**
* Set to true to disable automatically closing the dropdown after
* a selection has been made.
*/
ignoreSelect: {
type: Boolean,
value: false
}
},

Expand Down
13 changes: 11 additions & 2 deletions paper-dropdown-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@
on-iron-select="_onIronSelect"
on-iron-deselect="_onIronDeselect"
opened="{{opened}}"
close-on-activate
allow-outside-scroll="[[allowOutsideScroll]]"
restore-focus-on-close="[[restoreFocusOnClose]]">
restore-focus-on-close="[[restoreFocusOnClose]]"
ignore-select="[[ignoreSelect]]">
<!-- support hybrid mode: user might be using paper-menu-button 1.x which distributes via <content> -->
<div class="dropdown-trigger" slot="dropdown-trigger">
<paper-ripple></paper-ripple>
Expand Down Expand Up @@ -278,6 +278,15 @@
type: Boolean,
value: true
},

/**
* Set to true to disable automatically closing the dropdown after
* a selection has been made.
*/
ignoreSelect: {
type: Boolean,
value: false
}
},

listeners: {
Expand Down
31 changes: 31 additions & 0 deletions test/paper-dropdown-menu-light.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@
</template>
</test-fixture>

<test-fixture id="MultiselectDropdownMenu">
<template>
<paper-dropdown-menu-light no-animations ignore-select>
<paper-listbox slot="dropdown-content" class="dropdown-content" selected-values="[0,1]" multi>
<paper-item>Foo</paper-item>
<paper-item>Bar</paper-item>
<paper-item>Baz</paper-item>
</paper-listbox>
</paper-dropdown-menu-light>
</template>
</test-fixture>

<script>

function runAfterOpen(dropdownMenu, callback) {
Expand Down Expand Up @@ -225,6 +237,25 @@
expect(dropdownMenu.selectedItemLabel).to.be.equal('Foo textContent');
});
});

suite('multiselect', function() {
setup(function(done) {
dropdownMenu = fixture('MultiselectDropdownMenu');
content = Polymer.dom(dropdownMenu).querySelector('[slot="dropdown-content"]');
// Wait for distribution.
Polymer.Base.async(function() {
done();
});
});

test('makes multiple selections', function() {
expect(content.selectedValues.length).to.be.equal(2);
});

test('ignores select', function() {
expect(dropdownMenu.ignoreSelect).to.be.true;
});
});
});
</script>

Expand Down
31 changes: 31 additions & 0 deletions test/paper-dropdown-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@
</template>
</test-fixture>

<test-fixture id="MultiselectDropdownMenu">
<template>
<paper-dropdown-menu no-animations ignore-select>
<paper-listbox slot="dropdown-content" class="dropdown-content" selected-values="[0,1]" multi>
<paper-item>Foo</paper-item>
<paper-item>Bar</paper-item>
<paper-item>Baz</paper-item>
</paper-listbox>
</paper-dropdown-menu>
</template>
</test-fixture>

<script>

function runAfterOpen(dropdownMenu, callback) {
Expand Down Expand Up @@ -225,6 +237,25 @@
expect(dropdownMenu.selectedItemLabel).to.be.equal('Foo textContent');
});
});

suite('multiselect', function() {
setup(function(done) {
dropdownMenu = fixture('MultiselectDropdownMenu');
content = Polymer.dom(dropdownMenu).querySelector('[slot="dropdown-content"]');
// Wait for distribution.
Polymer.Base.async(function() {
done();
});
});

test('makes multiple selections', function() {
expect(content.selectedValues.length).to.be.equal(2);
});

test('ignores select', function() {
expect(dropdownMenu.ignoreSelect).to.be.true;
});
});
});
</script>

Expand Down