Skip to content

Commit

Permalink
Fixed not being able to provide custom suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuesos committed Aug 23, 2017
1 parent fe4cbea commit 457368d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## Release 3.0.2 (2017-08-23)
### Bug Fixes
- It is now again possible to add a custom `paper-input` suffix. See the new demo.

## Release 3.0.1 (2017-08-12)
### Bug Fixes
- Removed duplicated `auto-validate` attribute from paper-autocomplete (thanks to @kaseyhinton).
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paper-autocomplete",
"version": "3.0.1",
"version": "3.0.2",
"authors": [
"S. Francis",
"Rodolfo Oviedo <[email protected]>",
Expand Down
13 changes: 13 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../../paper-toast/paper-toast.html">
<link rel="import" href="../../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../iron-form/iron-form.html">
<link rel="import" href="../../elliptical-sass/elliptical-sass.html">
<link rel="import" href="../../css-docs/css-docs.html">
Expand Down Expand Up @@ -89,6 +90,18 @@ <h3>Local Data-Source Binding</h3>
</template>
</demo-snippet>

<demo-snippet>
<template>
<paper-autocomplete id="suffix"
class="autocomplete-states"
label="Using suffix"
id="suffix-example">

<paper-icon-button slot="suffix" suffix icon="search"></paper-icon-button>
</paper-autocomplete>
</template>
</demo-snippet>

<h3>Remote Data-Source Binding</h3>
<p>
Mock remote users data binding. Remote data binding delegates the responsibility of filtering the data source
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "paper-autocomplete",
"description": "Material Design autocomplete component.",
"version": "3.0.1",
"version": "3.0.2",
"author": "S. Francis <[email protected]>",
"contributors": [
"Rodolfo Oviedo <[email protected]>",
Expand Down
4 changes: 4 additions & 0 deletions paper-autocomplete-suggestions.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
**From v3.x.x, this component only works with Polymer 1.7+ or 2.0+.**
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/ellipticaljs/paper-autocomplete)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/jhuesos.svg)](https://saucelabs.com/u/jhuesos)
Allows to add autocomplete capabilities to any input field. This is desirable when you have an input field with custom
logic and you just want to add the feature to help users with the selection. If you want to use it in combination with
a regular `<paper-input>`, you can use `<paper-autocomplete>`.
Expand Down
8 changes: 6 additions & 2 deletions paper-autocomplete.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
**From v3.x.x, this component only works with Polymer 1.7+ or 2.0+.**
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/ellipticaljs/paper-autocomplete)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/jhuesos.svg)](https://saucelabs.com/u/jhuesos)
paper-autocomplete extends earlier efforts such as this (https://github.com/rodo1111/paper-input-autocomplete)
to provide keyboard support, remote binding and results scrolling.
Expand Down Expand Up @@ -139,7 +143,6 @@

#clear {
display: none;
margin-top: auto;
line-height: 8px;
}

Expand Down Expand Up @@ -189,6 +192,7 @@

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

this.$.clear.style.display = 'block';
this.$.clear.style.display = 'inline-block';
this._isClearButtonVisible = true;
},

Expand Down
3 changes: 2 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
WCT.loadSuites([
'paper-autocomplete_test_local.html',
'paper-autocomplete_test_local.html?dom=shadow',
'paper-autocomplete_test_multi.html'
'paper-autocomplete_test_multi.html',
'paper-autocomplete_test_multi.html?dom=shadow'
]);
</script>

Expand Down
31 changes: 26 additions & 5 deletions test/paper-autocomplete_test_local.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
</paper-autocomplete>
</template>
</test-fixture>

<test-fixture id='suffixTest'>
<template>
<paper-autocomplete
id='suffix'
name='state'>
<button slot="suffix" suffix id='suffixBtn'>OK</button>
</paper-autocomplete>
</template>
</test-fixture>

<script>
describe('paper-autocomplete', function () {
var element, states;
Expand Down Expand Up @@ -236,14 +247,13 @@

doInput(input, 'Ne');
displayStyle = getClearButtonDisplayStyle();
expect(displayStyle).to.equal('none');
expect(displayStyle).to.equal('');
});

it('should display of the clear button when the option is set to false (default)', function () {
doInput(input, 'New');
displayStyle = getClearButtonDisplayStyle();
expect(displayStyle).to.equal('block');

expect(displayStyle).to.equal('inline-block');
});
});
});
Expand All @@ -264,7 +274,7 @@
doInput(input, 'A');

expect(element.$.paperAutocompleteSuggestions.$.suggestionsWrapper.style.display).to.equal('block');
expect(getClearButtonDisplayStyle()).to.equal('block');
expect(getClearButtonDisplayStyle()).to.equal('inline-block');

element.hideSuggestions();

Expand Down Expand Up @@ -311,6 +321,17 @@
});
});

it('element with slot=preffix should be added as paper-input suffix', function () {
var suffixElement = fixture('suffixTest');
var children = Polymer.dom(suffixElement.$$('paper-input').$$('paper-input-container')).getEffectiveChildNodes();
var isSuffixBtnAdded = [].slice.call(children)
.filter(function (ele) {
return ele.id === 'suffixBtn';
}).length === 1;

expect(isSuffixBtnAdded).to.be.true;
});

a11ySuite('basic', ['badAriaAttributeValue', 'nonExistentRelatedElement']);

// HELPERS
Expand All @@ -323,7 +344,7 @@
}

function getClearButtonDisplayStyle() {
return window.getComputedStyle(element.$.clear).getPropertyValue('display');
return element.$.clear.style.display;
}
});
</script>
Expand Down

0 comments on commit 457368d

Please sign in to comment.