Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion components/SLDSLookup/Menu/Item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Item extends React.Component {

handleClick(e){
EventUtil.trapImmediate(e);
console.log('>>> this.props.id: ',this.props.id);
return this.props.onSelect(this.props.id);
}

Expand Down
12 changes: 5 additions & 7 deletions components/SLDSLookup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class SLDSLookup extends React.Component {
super(props);

//Dynamically assign ids to list items to reference for focusing and selecting items
// this.props.items.map((item, index) => { return item.id = 'item-' + index; })
this.modifyItems();

this.state = {
Expand Down Expand Up @@ -78,7 +77,7 @@ class SLDSLookup extends React.Component {
selectedIndex: index,
searchTerm: null
});
if(this.props.onItemSelect) this.props.onItemSelect();
if(this.props.onItemSelect) this.props.onItemSelect(itemId);
}

handleDeleteSelected() {
Expand Down Expand Up @@ -131,6 +130,7 @@ class SLDSLookup extends React.Component {
handleChange(event) {
const target = event.target || event.currentTarget;
this.setState({searchTerm: target.value});
if(this.props.onChange) this.props.onChange(target.value);
}

handleKeyDown(event) {
Expand Down Expand Up @@ -228,7 +228,7 @@ class SLDSLookup extends React.Component {
</span>
<SLDSButton
label='Press delete to remove'
tabindex="-1"
tabIndex="-1"
variant='icon'
iconName='close'
iconSize='medium'
Expand Down Expand Up @@ -295,6 +295,7 @@ SLDSLookup.propTypes = {
type: React.PropTypes.string,
filterWith: React.PropTypes.func,
onItemSelect: React.PropTypes.func,
onChange: React.PropTypes.func,
onNewItem: React.PropTypes.func,
onSearchRecords: React.PropTypes.func,
modal: React.PropTypes["bool"],
Expand All @@ -304,10 +305,7 @@ SLDSLookup.propTypes = {
SLDSLookup.defaultProps = {
filterWith: defaultFilter,
modal: false,
disabled: false,
onItemSelect: function(item){
//console.log('onItemSelect should be defined');
}
disabled: false
};

module.exports = SLDSLookup;
Expand Down
10 changes: 9 additions & 1 deletion demo/code-snippets/SLDSLookupPage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,13 @@ const items = [
{label:'Acme Construction'}
];

<SLDSLookup items={items} label="Accounts" type="account" onNewItem={this.newItem} onSearchRecords={this.searchRecords} />
<SLDSLookup
items={items}
label="Accounts"
type="account"
onChange={this.onChange}
onItemSelect={this.onItemSelect}
onNewItem={this.newItem}
onSearchRecords={this.searchRecords} />


8 changes: 7 additions & 1 deletion demo/pages/HomePage/LookupBaseDynamicSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ module.exports = React.createClass( {
alert('Search Records Clicked');
},

onChange(newValue){
console.log('New search term: ', newValue);
},

handleItemSelect(item){
console.log(item);
},
Expand All @@ -55,10 +59,12 @@ module.exports = React.createClass( {
<div className="slds-p-around--medium">
Dynamic list
<div className="slds-p-vertical--large">
<SLDSLookup
<SLDSLookup
items={this.state.items}
label="Accounts"
type="account"
onChange={this.onChange}
onItemSelect={this.selectItem}
onNewItem={this.newItem}
onItemSelect={this.handleItemSelect}
onSearchRecords={this.searchRecords}
Expand Down
12 changes: 11 additions & 1 deletion demo/pages/HomePage/LookupBaseSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ module.exports = React.createClass( {
alert('Search Records Clicked');
},

onChange(newValue){
console.log('New search term: ', newValue);
},

selectItem(item){
console.log(item + ' Selected');
},

render() {
return (

Expand All @@ -60,10 +68,12 @@ module.exports = React.createClass( {
</PrismCode>

<div className="slds-p-vertical--large">
<SLDSLookup
<SLDSLookup
items={items}
label="Accounts"
type="account"
onChange={this.onChange}
onItemSelect={this.selectItem}
onNewItem={this.newItem}
onSearchRecords={this.searchRecords}
/>
Expand Down