Skip to content

Commit 457368d

Browse files
committed
Fixed not being able to provide custom suffix
1 parent fe4cbea commit 457368d

8 files changed

+57
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This component follows *Semantic Versioning* (aka SemVer), visit (http://semver.org/) to learn more about it.
44

5+
## Release 3.0.2 (2017-08-23)
6+
### Bug Fixes
7+
- It is now again possible to add a custom `paper-input` suffix. See the new demo.
8+
59
## Release 3.0.1 (2017-08-12)
610
### Bug Fixes
711
- Removed duplicated `auto-validate` attribute from paper-autocomplete (thanks to @kaseyhinton).

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "paper-autocomplete",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"authors": [
55
"S. Francis",
66
"Rodolfo Oviedo <[email protected]>",

demo/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
1111
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
1212
<link rel="import" href="../../paper-toast/paper-toast.html">
13+
<link rel="import" href="../../paper-icon-button/paper-icon-button.html">
1314
<link rel="import" href="../../iron-form/iron-form.html">
1415
<link rel="import" href="../../elliptical-sass/elliptical-sass.html">
1516
<link rel="import" href="../../css-docs/css-docs.html">
@@ -89,6 +90,18 @@ <h3>Local Data-Source Binding</h3>
8990
</template>
9091
</demo-snippet>
9192

93+
<demo-snippet>
94+
<template>
95+
<paper-autocomplete id="suffix"
96+
class="autocomplete-states"
97+
label="Using suffix"
98+
id="suffix-example">
99+
100+
<paper-icon-button slot="suffix" suffix icon="search"></paper-icon-button>
101+
</paper-autocomplete>
102+
</template>
103+
</demo-snippet>
104+
92105
<h3>Remote Data-Source Binding</h3>
93106
<p>
94107
Mock remote users data binding. Remote data binding delegates the responsibility of filtering the data source

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "paper-autocomplete",
33
"description": "Material Design autocomplete component.",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"author": "S. Francis <[email protected]>",
66
"contributors": [
77
"Rodolfo Oviedo <[email protected]>",

paper-autocomplete-suggestions.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
99
**From v3.x.x, this component only works with Polymer 1.7+ or 2.0+.**
1010
11+
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/ellipticaljs/paper-autocomplete)
12+
13+
[![Sauce Test Status](https://saucelabs.com/browser-matrix/jhuesos.svg)](https://saucelabs.com/u/jhuesos)
14+
1115
Allows to add autocomplete capabilities to any input field. This is desirable when you have an input field with custom
1216
logic and you just want to add the feature to help users with the selection. If you want to use it in combination with
1317
a regular `<paper-input>`, you can use `<paper-autocomplete>`.

paper-autocomplete.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
1414
**From v3.x.x, this component only works with Polymer 1.7+ or 2.0+.**
1515
16+
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/ellipticaljs/paper-autocomplete)
17+
18+
[![Sauce Test Status](https://saucelabs.com/browser-matrix/jhuesos.svg)](https://saucelabs.com/u/jhuesos)
19+
1620
paper-autocomplete extends earlier efforts such as this (https://github.com/rodo1111/paper-input-autocomplete)
1721
to provide keyboard support, remote binding and results scrolling.
1822
@@ -139,7 +143,6 @@
139143

140144
#clear {
141145
display: none;
142-
margin-top: auto;
143146
line-height: 8px;
144147
}
145148

@@ -189,6 +192,7 @@
189192

190193
<!-- TODO: remove tabindex workaround when is fixed https://github.com/PolymerElements/paper-input/issues/324 -->
191194
<paper-icon-button slot="suffix" suffix id="clear" icon="clear" on-click="_clear" tabindex="-1"></paper-icon-button>
195+
<slot name="suffix" slot="suffix"></slot>
192196
</paper-input>
193197
<!-- to announce current selection to screen reader -->
194198
<span id="autocompleteStatus" role="status" class="sr-only">[[_highlightedSuggestion.textValue]]</span>
@@ -511,7 +515,7 @@
511515
return;
512516
}
513517

514-
this.$.clear.style.display = 'block';
518+
this.$.clear.style.display = 'inline-block';
515519
this._isClearButtonVisible = true;
516520
},
517521

test/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
WCT.loadSuites([
2020
'paper-autocomplete_test_local.html',
2121
'paper-autocomplete_test_local.html?dom=shadow',
22-
'paper-autocomplete_test_multi.html'
22+
'paper-autocomplete_test_multi.html',
23+
'paper-autocomplete_test_multi.html?dom=shadow'
2324
]);
2425
</script>
2526

test/paper-autocomplete_test_local.html

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
</paper-autocomplete>
2525
</template>
2626
</test-fixture>
27+
28+
<test-fixture id='suffixTest'>
29+
<template>
30+
<paper-autocomplete
31+
id='suffix'
32+
name='state'>
33+
<button slot="suffix" suffix id='suffixBtn'>OK</button>
34+
</paper-autocomplete>
35+
</template>
36+
</test-fixture>
37+
2738
<script>
2839
describe('paper-autocomplete', function () {
2940
var element, states;
@@ -236,14 +247,13 @@
236247

237248
doInput(input, 'Ne');
238249
displayStyle = getClearButtonDisplayStyle();
239-
expect(displayStyle).to.equal('none');
250+
expect(displayStyle).to.equal('');
240251
});
241252

242253
it('should display of the clear button when the option is set to false (default)', function () {
243254
doInput(input, 'New');
244255
displayStyle = getClearButtonDisplayStyle();
245-
expect(displayStyle).to.equal('block');
246-
256+
expect(displayStyle).to.equal('inline-block');
247257
});
248258
});
249259
});
@@ -264,7 +274,7 @@
264274
doInput(input, 'A');
265275

266276
expect(element.$.paperAutocompleteSuggestions.$.suggestionsWrapper.style.display).to.equal('block');
267-
expect(getClearButtonDisplayStyle()).to.equal('block');
277+
expect(getClearButtonDisplayStyle()).to.equal('inline-block');
268278

269279
element.hideSuggestions();
270280

@@ -311,6 +321,17 @@
311321
});
312322
});
313323

324+
it('element with slot=preffix should be added as paper-input suffix', function () {
325+
var suffixElement = fixture('suffixTest');
326+
var children = Polymer.dom(suffixElement.$$('paper-input').$$('paper-input-container')).getEffectiveChildNodes();
327+
var isSuffixBtnAdded = [].slice.call(children)
328+
.filter(function (ele) {
329+
return ele.id === 'suffixBtn';
330+
}).length === 1;
331+
332+
expect(isSuffixBtnAdded).to.be.true;
333+
});
334+
314335
a11ySuite('basic', ['badAriaAttributeValue', 'nonExistentRelatedElement']);
315336

316337
// HELPERS
@@ -323,7 +344,7 @@
323344
}
324345

325346
function getClearButtonDisplayStyle() {
326-
return window.getComputedStyle(element.$.clear).getPropertyValue('display');
347+
return element.$.clear.style.display;
327348
}
328349
});
329350
</script>

0 commit comments

Comments
 (0)