Skip to content

Commit

Permalink
Fixed chrome non-unique id error (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
itzzshirlayyy authored and sks committed Sep 5, 2018
1 parent b111203 commit c0d3a90
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v4.7.8
==================
* Removed id #searchbox from px-dropdown and used the class variable .search__box.
* This ensures no duplicate 'non-unique id' error that chrome console checks for.

v4.7.6
==================
* fix event documentation
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": "px-dropdown",
"version": "4.7.7",
"version": "4.7.8",
"main": [
"px-dropdown.html"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "px-dropdown",
"author": "General Electric",
"description": "A Predix UI Dropdown component",
"version": "4.7.7",
"version": "4.7.8",
"extName": null,
"repository": {
"type": "git",
Expand Down
9 changes: 4 additions & 5 deletions px-dropdown-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<div class="u-p- fixed">
<div class="search__form">
<input
id="searchbox"
class="text-input search__box"
disabled$="[[disabled]]"
placeholder="{{placeholder}}"
Expand Down Expand Up @@ -728,7 +727,7 @@
&& !node.hasAttribute('disabled') && !node.classList.contains('hidden'));
}),
focused = options.indexOf(this._focusedOption),
searchFocused = this.searchMode && Polymer.dom(this.$.dropdown).querySelector(':focus') === Polymer.dom(this.$.dropdown).querySelector('#searchbox');
searchFocused = this.searchMode && Polymer.dom(this.$.dropdown).querySelector(':focus') === Polymer.dom(this.$.dropdown).querySelector('.search__box');
switch (keyPressed) {
case 'space':
case 'enter':
Expand Down Expand Up @@ -768,11 +767,11 @@
}
// If nothing is focused and search-mode is true, move to the search box
else if (focused === -1 && this.searchMode && !searchFocused) {
Polymer.dom(this.$.dropdown).querySelector('#searchbox').focus();
Polymer.dom(this.$.dropdown).querySelector('.search__box').focus();
}
// If searchbox is focused, move to the first option
else if (searchFocused) {
Polymer.dom(this.$.dropdown).querySelector('#searchbox').blur();
Polymer.dom(this.$.dropdown).querySelector('.search__box').blur();
this.$.trigger.focus();
this._setFocusedOption(options[0]);
}
Expand All @@ -794,7 +793,7 @@
}
// If the first item is focused and search-mode is true, move to the search box
else if (focused === 0 && this.searchMode && !searchFocused) {
Polymer.dom(this.$.dropdown).querySelector('#searchbox').focus();
Polymer.dom(this.$.dropdown).querySelector('.search__box').focus();
this._setFocusedOption(null, options[0]);
}
// Else focus the last item in the list
Expand Down
2 changes: 1 addition & 1 deletion test/px-dropdown-custom-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ describe('Custom Automation Tests for search feature px-dropdown', function (don
it('Check that search box appears when in search mode',
function (done) {
flush(()=>{
let input = Polymer.dom(px_dropdown.$.content.root).querySelector('#searchbox');
let input = Polymer.dom(px_dropdown.$.content.root).querySelector('.search__box');
assert.isTrue(input.classList.contains('text-input'));
done();
});
Expand Down

0 comments on commit c0d3a90

Please sign in to comment.