Skip to content

Commit 0659e16

Browse files
committed
Merge branch 'master' into lookup
2 parents 641db9d + 13ac35b commit 0659e16

File tree

13 files changed

+73
-37
lines changed

13 files changed

+73
-37
lines changed

components/SLDSLookup/Menu/Item/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Item extends React.Component {
3434

3535
handleClick(e){
3636
EventUtil.trapImmediate(e);
37-
return this.props.onSelect(this.props.id);
37+
return this.props.onSelect(this.props.id, this.props.data);
3838
}
3939

4040
//Scroll menu item based on up/down mouse keys (assumes all items are the same height)

components/SLDSLookup/Menu/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Menu extends React.Component {
102102
setFocus={this.props.setFocus}
103103
handleItemFocus={this.handleItemFocus.bind(this)}
104104
onSelect={this.props.onSelect}
105-
data={c}
105+
data={c.data}
106106
>
107107
{c}
108108
</Item>

components/SLDSLookup/index.jsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ class SLDSLookup extends React.Component {
2525
super(props);
2626

2727
//Dynamically assign ids to list items to reference for focusing and selecting items
28-
this.modifyItems();
2928

3029
this.state = {
3130
searchTerm: '',
3231
isOpen:false,
3332
currentFocus:null,
3433
focusIndex:null,
3534
selectedIndex: null,
36-
listLength:this.props.items.length
35+
listLength:this.props.items.length,
36+
items:[]
3737
};
38+
39+
40+
}
41+
42+
componentDidMount(){
43+
this.modifyItems();
3844
}
3945

4046
componentDidUpdate(prevProps, prevState){
@@ -71,13 +77,13 @@ class SLDSLookup extends React.Component {
7177

7278
//=================================================
7379
// Select menu item (onClick or on key enter/space)
74-
selectItem(itemId){
75-
let index = itemId.replace('item-', '');
80+
selectItem(itemId,data){
81+
const index = itemId.replace('item-', '');
7682
this.setState({
7783
selectedIndex: index,
7884
searchTerm: null
7985
});
80-
if(this.props.onItemSelect) this.props.onItemSelect(itemId);
86+
if(this.props.onItemSelect) this.props.onItemSelect(data);
8187
}
8288

8389
handleDeleteSelected() {
@@ -186,7 +192,7 @@ class SLDSLookup extends React.Component {
186192
type={this.props.type}
187193
focusIndex={this.state.focusIndex}
188194
listLength={this.state.listLength}
189-
items={this.props.items}
195+
items={this.state.items}
190196
filterWith={this.props.filterWith}
191197
getListLength={this.getListLength.bind(this)}
192198
setFocus={this.setFocus.bind(this)}
@@ -242,7 +248,15 @@ class SLDSLookup extends React.Component {
242248
}
243249

244250
modifyItems () {
245-
this.props.items.map((item, index) => { return item.id = 'item-' + index; })
251+
const items = this.props.items.map((item, index) => {
252+
return {
253+
id : 'item-' + index,
254+
label: item.label,
255+
data : item
256+
}
257+
});
258+
259+
this.setState({items:items});
246260
}
247261

248262
componentWillReceiveProps (newProps) {

demo/pages/HomePage/LookupBaseDynamicSection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = React.createClass( {
5050
},
5151

5252
handleItemSelect(item){
53-
console.log(item);
53+
console.dir(item);
5454
},
5555

5656
render() {

demo/pages/HomePage/LookupBaseSection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = React.createClass( {
4949
},
5050

5151
selectItem(item){
52-
console.log(item + ' Selected');
52+
console.log(item , ' Selected');
5353
},
5454

5555
getHeader(){

dist/design-system-react.js

Lines changed: 22 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/design-system-react.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/design-system-react.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/design-system-react.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/SLDSLookup/Menu/Item/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var Item = (function (_React$Component) {
5858
key: 'handleClick',
5959
value: function handleClick(e) {
6060
_utils.EventUtil.trapImmediate(e);
61-
return this.props.onSelect(this.props.id);
61+
return this.props.onSelect(this.props.id, this.props.data);
6262
}
6363

6464
//Scroll menu item based on up/down mouse keys (assumes all items are the same height)

0 commit comments

Comments
 (0)