File tree 3 files changed +15
-8
lines changed
3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,16 @@ class IndexSelector extends React.Component {
8
8
render ( ) {
9
9
var currentIndex = this . props . currentIndex ;
10
10
var indices = this . props . indices ;
11
- var cssClass = this . props . cssClass ;
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
+ }
12
17
13
18
return (
14
19
< select
15
- className = { cssClass }
20
+ { ... htmlAttributes }
16
21
onChange = { this . handleChange . bind ( this ) }
17
22
value = { currentIndex }
18
23
>
@@ -25,8 +30,8 @@ class IndexSelector extends React.Component {
25
30
}
26
31
27
32
IndexSelector . propTypes = {
28
- cssClass : React . PropTypes . string ,
29
33
currentIndex : React . PropTypes . string ,
34
+ htmlAttributes : React . PropTypes . object ,
30
35
indices : React . PropTypes . array ,
31
36
setIndex : React . PropTypes . func
32
37
} ;
Original file line number Diff line number Diff line change @@ -30,7 +30,10 @@ 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
- cssClass : 'form-control'
33
+ htmlAttributes : {
34
+ id : 'indexSelectorDropdown' ,
35
+ class : 'form-control'
36
+ }
34
37
} )
35
38
) ;
36
39
Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
- var cx = require ( 'classnames' ) ;
3
2
4
3
var findIndex = require ( 'lodash/array/findIndex' ) ;
5
4
var utils = require ( '../lib/widget-utils.js' ) ;
6
5
7
6
function indexSelector ( {
8
7
container = null ,
9
- cssClass = null ,
8
+ htmlAttributes = { } ,
10
9
indices = null
11
10
} ) {
12
11
var IndexSelector = require ( '../components/IndexSelector' ) ;
13
12
var containerNode = utils . getContainerNode ( container ) ;
14
13
15
- var usage = 'Usage: indexSelector({container, indices[, cssClass ]})' ;
14
+ var usage = 'Usage: indexSelector({container, indices[, htmlAttributes ]})' ;
16
15
if ( container === null || indices === null ) {
17
16
throw new Error ( usage ) ;
18
17
}
@@ -29,7 +28,7 @@ function indexSelector({
29
28
render : function ( results , state , helper ) {
30
29
React . render (
31
30
< IndexSelector
32
- cssClass = { cx ( cssClass ) }
31
+ htmlAttributes = { htmlAttributes }
33
32
currentIndex = { helper . getIndex ( ) }
34
33
indices = { indices }
35
34
setIndex = { helper . setIndex . bind ( helper ) }
You can’t perform that action at this time.
0 commit comments