File tree 4 files changed +13
-16
lines changed
4 files changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -8,16 +8,13 @@ class IndexSelector extends React.Component {
8
8
render ( ) {
9
9
var currentIndex = this . props . currentIndex ;
10
10
var indices = this . props . indices ;
11
- var htmlAttributes = this . props . htmlAttributes ;
12
- // React needs `className` in place of `class`
13
- if ( htmlAttributes . class ) {
14
- htmlAttributes . className = htmlAttributes . class ;
15
- htmlAttributes . class = null ;
16
- }
11
+ var cssClass = this . props . cssClass ;
12
+ var selectId = this . props . containerId + '-select' ;
17
13
18
14
return (
19
15
< select
20
- { ...htmlAttributes }
16
+ id = { selectId }
17
+ className = { cssClass }
21
18
onChange = { this . handleChange . bind ( this ) }
22
19
value = { currentIndex }
23
20
>
@@ -30,8 +27,9 @@ class IndexSelector extends React.Component {
30
27
}
31
28
32
29
IndexSelector . propTypes = {
30
+ containerId : React . PropTypes . string ,
31
+ cssClass : React . PropTypes . string ,
33
32
currentIndex : React . PropTypes . string ,
34
- htmlAttributes : React . PropTypes . object ,
35
33
indices : React . PropTypes . array ,
36
34
setIndex : React . PropTypes . func
37
35
} ;
Original file line number Diff line number Diff line change @@ -30,10 +30,7 @@ search.addWidget(
30
30
{ name : 'instant_search_price_asc' , label : 'Lowest price' } ,
31
31
{ name : 'instant_search_price_desc' , label : 'Highest price' }
32
32
] ,
33
- htmlAttributes : {
34
- id : 'indexSelectorDropdown' ,
35
- class : 'form-control'
36
- }
33
+ cssClass : 'form-control'
37
34
} )
38
35
) ;
39
36
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ <h1>Instant search demo <small>using instantsearch.js</small></h1>
46
46
< div class ="col-md-4 text-right ">
47
47
< div class ="form-inline ">
48
48
< div class ="form-group ">
49
- < label > Sort by:</ label >
49
+ < label for =" index-selector-select " > Sort by:</ label >
50
50
< span id ="index-selector "> </ span >
51
51
</ div >
52
52
</ div >
Original file line number Diff line number Diff line change @@ -7,12 +7,12 @@ var utils = require('../lib/widget-utils.js');
7
7
* Instantiate a dropdown element to choose the current targeted index
8
8
* @param {String|DOMElement } options.container Valid CSS Selector as a string or DOMElement
9
9
* @param {Array } options.indices Array of objects defining the different indices to choose from. Each object must contain a `name` and `label` key.
10
- * @param {String } [ options.htmlAttributes] Object of html attributes to be passed to the generated ` select` element
10
+ * @param {String } options.cssClass Class name(s) to be added to the generated select element
11
11
* @return {Object }
12
12
*/
13
13
function indexSelector ( {
14
14
container = null ,
15
- htmlAttributes = { } ,
15
+ cssClass = { } ,
16
16
indices = null
17
17
} ) {
18
18
var IndexSelector = require ( '../components/IndexSelector' ) ;
@@ -33,9 +33,11 @@ function indexSelector({
33
33
} ,
34
34
35
35
render : function ( results , state , helper ) {
36
+ var containerId = containerNode . id ;
36
37
React . render (
37
38
< IndexSelector
38
- htmlAttributes = { htmlAttributes }
39
+ containerId = { containerId }
40
+ cssClass = { cssClass }
39
41
currentIndex = { helper . getIndex ( ) }
40
42
indices = { indices }
41
43
setIndex = { helper . setIndex . bind ( helper ) }
You can’t perform that action at this time.
0 commit comments