This repository was archived by the owner on Jul 19, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +7
-17
lines changed Expand file tree Collapse file tree 5 files changed +7
-17
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,15 @@ let App = React.createClass({
16
16
return (
17
17
< div >
18
18
< h1 > Async Data</ h1 >
19
-
20
19
< p >
21
20
Autocomplete works great with async data by allowing you to pass in
22
21
items. The < code > onChange</ code > event provides you the value to make
23
22
a server request with, then change state and pass in new items, it will
24
23
attempt to autocomplete the first one.
25
24
</ p >
26
-
25
+ < label htmlFor = "states-autocomplete" > Choose a state from the US </ label >
27
26
< Autocomplete
28
- labelText = "Choose a state from the US"
29
- inputProps = { { name : "US state" } }
27
+ inputProps = { { name : "US state" , id : "states-autocomplete" } }
30
28
ref = "autocomplete"
31
29
value = { this . state . value }
32
30
items = { this . state . unitedStates }
Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ let App = React.createClass({
21
21
look as well as the rendering of it. In this case we put headers for each
22
22
letter of the alphabet.
23
23
</ p >
24
+ < label htmlFor = "states-autocomplete" > Choose a state from the US</ label >
24
25
< Autocomplete
25
26
value = { this . state . value }
26
- labelText = "Choose a state from the US"
27
- inputProps = { { name : "US state" } }
27
+ inputProps = { { name : "US state" , id : "states-autocomplete" } }
28
28
items = { this . state . unitedStates }
29
29
getItemValue = { ( item ) => item . name }
30
30
onSelect = { value => this . setState ( { value, unitedStates : [ ] } ) }
Original file line number Diff line number Diff line change @@ -10,16 +10,14 @@ let App = React.createClass({
10
10
return (
11
11
< div >
12
12
< h1 > Basic Example with Static Data</ h1 >
13
-
14
13
< p >
15
14
When using static data, you use the client to sort and filter the items,
16
15
so < code > Autocomplete</ code > has methods baked in to help.
17
16
</ p >
18
-
17
+ < label htmlFor = "states-autocomplete" > Choose a state from the US </ label >
19
18
< Autocomplete
20
19
value = { this . state . value }
21
- labelText = "Choose a state from the US"
22
- inputProps = { { name : "US state" } }
20
+ inputProps = { { name : "US state" , id : "states-autocomplete" } }
23
21
items = { getStates ( ) }
24
22
getItemValue = { ( item ) => item . name }
25
23
shouldItemRender = { matchStateToTerm }
Original file line number Diff line number Diff line change 1
1
const React = require ( 'react' )
2
- const lodash = require ( 'lodash' )
3
2
const scrollIntoView = require ( 'dom-scroll-into-view' )
4
3
5
4
let _debugStates = [ ]
@@ -49,7 +48,6 @@ let Autocomplete = React.createClass({
49
48
} ,
50
49
51
50
componentWillMount ( ) {
52
- this . id = lodash . uniqueId ( 'autocomplete-' ) ;
53
51
this . _ignoreBlur = false
54
52
this . _performAutoCompleteOnUpdate = false
55
53
this . _performAutoCompleteOnKeyUp = false
@@ -298,11 +296,9 @@ let Autocomplete = React.createClass({
298
296
state : this . state
299
297
} )
300
298
}
299
+
301
300
return (
302
301
< div style = { { display : 'inline-block' } } >
303
- < label htmlFor = { this . id } ref = "label" >
304
- { this . props . labelText }
305
- </ label >
306
302
< input
307
303
{ ...this . props . inputProps }
308
304
role = "combobox"
@@ -315,7 +311,6 @@ let Autocomplete = React.createClass({
315
311
onKeyUp = { ( event ) => this . handleKeyUp ( event ) }
316
312
onClick = { this . handleInputClick }
317
313
value = { this . props . value }
318
- id = { this . id }
319
314
/>
320
315
{ this . state . isOpen && this . renderMenu ( ) }
321
316
{ this . props . debug && (
Original file line number Diff line number Diff line change 48
48
"dependencies" : {
49
49
"babel-preset-es2015" : " ^6.5.0" ,
50
50
"dom-scroll-into-view" : " 1.0.1" ,
51
- "lodash" : " ^4.5.0" ,
52
51
"react" : " ^0.14.7" ,
53
52
"react-dom" : " ^0.14.7"
54
53
}
You can’t perform that action at this time.
0 commit comments