Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Commit a691cec

Browse files
committed
Remove lodash dependency and hardcoded input label
1 parent 6c7a7cf commit a691cec

File tree

5 files changed

+7
-17
lines changed

5 files changed

+7
-17
lines changed

examples/async-data/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ let App = React.createClass({
1616
return (
1717
<div>
1818
<h1>Async Data</h1>
19-
2019
<p>
2120
Autocomplete works great with async data by allowing you to pass in
2221
items. The <code>onChange</code> event provides you the value to make
2322
a server request with, then change state and pass in new items, it will
2423
attempt to autocomplete the first one.
2524
</p>
26-
25+
<label htmlFor="states-autocomplete">Choose a state from the US</label>
2726
<Autocomplete
28-
labelText="Choose a state from the US"
29-
inputProps={{name: "US state"}}
27+
inputProps={{name: "US state", id: "states-autocomplete"}}
3028
ref="autocomplete"
3129
value={this.state.value}
3230
items={this.state.unitedStates}

examples/custom-menu/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ let App = React.createClass({
2121
look as well as the rendering of it. In this case we put headers for each
2222
letter of the alphabet.
2323
</p>
24+
<label htmlFor="states-autocomplete">Choose a state from the US</label>
2425
<Autocomplete
2526
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"}}
2828
items={this.state.unitedStates}
2929
getItemValue={(item) => item.name}
3030
onSelect={value => this.setState({ value, unitedStates: [] }) }

examples/static-data/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ let App = React.createClass({
1010
return (
1111
<div>
1212
<h1>Basic Example with Static Data</h1>
13-
1413
<p>
1514
When using static data, you use the client to sort and filter the items,
1615
so <code>Autocomplete</code> has methods baked in to help.
1716
</p>
18-
17+
<label htmlFor="states-autocomplete">Choose a state from the US</label>
1918
<Autocomplete
2019
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"}}
2321
items={getStates()}
2422
getItemValue={(item) => item.name}
2523
shouldItemRender={matchStateToTerm}

lib/Autocomplete.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const React = require('react')
2-
const lodash = require('lodash')
32
const scrollIntoView = require('dom-scroll-into-view')
43

54
let _debugStates = []
@@ -49,7 +48,6 @@ let Autocomplete = React.createClass({
4948
},
5049

5150
componentWillMount () {
52-
this.id = lodash.uniqueId('autocomplete-');
5351
this._ignoreBlur = false
5452
this._performAutoCompleteOnUpdate = false
5553
this._performAutoCompleteOnKeyUp = false
@@ -298,11 +296,9 @@ let Autocomplete = React.createClass({
298296
state: this.state
299297
})
300298
}
299+
301300
return (
302301
<div style={{display: 'inline-block'}}>
303-
<label htmlFor={this.id} ref="label">
304-
{this.props.labelText}
305-
</label>
306302
<input
307303
{...this.props.inputProps}
308304
role="combobox"
@@ -315,7 +311,6 @@ let Autocomplete = React.createClass({
315311
onKeyUp={(event) => this.handleKeyUp(event)}
316312
onClick={this.handleInputClick}
317313
value={this.props.value}
318-
id={this.id}
319314
/>
320315
{this.state.isOpen && this.renderMenu()}
321316
{this.props.debug && (

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"dependencies": {
4949
"babel-preset-es2015": "^6.5.0",
5050
"dom-scroll-into-view": "1.0.1",
51-
"lodash": "^4.5.0",
5251
"react": "^0.14.7",
5352
"react-dom": "^0.14.7"
5453
}

0 commit comments

Comments
 (0)