File tree Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 11import React from 'react'
22import DataList from './components/DataList'
33import DataListOption from './components/DataListOption'
4+ import layout from './styles/react-datalist.styl'
45
56export default class ReactDataList extends React . Component {
67 constructor ( props ) {
@@ -13,10 +14,12 @@ export default class ReactDataList extends React.Component {
1314 }
1415 }
1516 render ( ) {
16- var options = this . filterOptions ( this . props . options , this . state . filter , this . useNative ( ) )
17+ var options = this . filterOptions ( this . props . options , this . state . filter , this . useNative ( ) )
1718 var extraClasses = this . props . className ? ' ' + this . props . className : '' ;
19+ var layoutstyle = ( this . props . includeLayoutStyle ) ? < style > { layout } </ style > : null
1820 return (
1921 < div className = "react-datalist-container" >
22+ { layoutstyle }
2023 < input ref = "theInput"
2124 list = { this . props . list }
2225 value = { this . state . filter }
@@ -168,8 +171,9 @@ export default class ReactDataList extends React.Component {
168171 }
169172}
170173ReactDataList . defaultProps = {
171- blurTimeout : 200 ,
172- hideOptionsOnBlur : true ,
173- hideOptionsOnEsc : true
174+ blurTimeout : 200 ,
175+ includeLayoutStyle : true ,
176+ hideOptionsOnBlur : true ,
177+ hideOptionsOnEsc : true
174178}
175179
Original file line number Diff line number Diff line change 1- div .react-datalist
1+ .react-datalist
22 margin : 0 !important
33 border : 1px solid #A1 C1 E7
44 max-height : 500px
@@ -16,4 +16,4 @@ div.react-datalist
1616 background-color #BA D4 FE
1717
1818 & .react-datalist-option-selected
19- background-color #BA D4 FE
19+ background-color #BA D4 FE
Original file line number Diff line number Diff line change @@ -339,4 +339,20 @@ describe('DATALIST', function() {
339339
340340 } )
341341
342+ it ( 'includes layout style by default' , function ( done ) {
343+ render ( { } , function ( ) {
344+ var style = nanodom ( 'style' )
345+ assert ( style . length == 1 )
346+ done ( )
347+ } )
348+ } )
349+
350+ it ( 'does not include layout style if includeLayoutStyle=false is passed as prop' , function ( done ) {
351+ render ( { includeLayoutStyle : false } , function ( ) {
352+ var style = nanodom ( 'style' )
353+ assert ( style . length == 0 )
354+ done ( )
355+ } )
356+ } )
357+
342358} )
You can’t perform that action at this time.
0 commit comments