Skip to content

Commit a1927db

Browse files
committed
Fix lookup onKeyUp bug when Lookup has section headers. Update examples.
1 parent c6a4776 commit a1927db

File tree

31 files changed

+1524
-15396
lines changed

31 files changed

+1524
-15396
lines changed

components/SLDSLookup/Menu/DefaultSectionHeader/index.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,38 @@
88
*/
99

1010
import React from 'react';
11-
import SLDSIcon from "../../../SLDSIcon";
1211
import { EventUtil } from '../../../utils';
1312

1413
const displayName = "LookupDefaultSectionHeader";
15-
const propTypes = {};
16-
const defaultProps = {};
14+
const propTypes = {
15+
data: React.PropTypes.object,
16+
key: React.PropTypes.string
17+
18+
};
1719

1820
class DefaultSectionHeader extends React.Component {
1921
constructor(props) {
2022
super(props);
2123
}
2224

23-
componentWillReceiveProps(nextProps){
24-
if(nextProps.isActive !== this.props.isActive && nextProps.isActive === true) {
25-
this.props.setFocus('searchRecords');
26-
}
27-
}
28-
29-
handleClick(){
30-
console.log('=====> Lookup Header Clicked');
31-
if(this.props.onClose){
32-
this.props.onClose();
33-
}
34-
}
35-
3625
handleMouseDown(event) {
3726
EventUtil.trapImmediate(event);
3827
}
3928

4029
render(){
4130
return (
42-
<li className="slds-lookup__item"
31+
<li className="slds-p-around--x-small"
4332
tabIndex="-1"
4433
>
45-
<a href="javascript:void()" tabIndex="-1">
4634
<span className="slds-m-left--x-small">
4735
<strong>{this.props.data.label}</strong>
4836
</span>
49-
</a>
5037
</li>
5138
)
5239
}
5340
}
5441

5542
DefaultSectionHeader.displayName = displayName;
5643
DefaultSectionHeader.propTypes = propTypes;
57-
DefaultSectionHeader.defaultProps = defaultProps;
5844

5945
module.exports = DefaultSectionHeader;

components/SLDSLookup/Menu/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Menu extends React.Component {
6464

6565
filterEmptySections(items){
6666
const result = [];
67-
items.forEach((item,index)=>{
67+
items.forEach((item,index) => {
6868
if(item && item.data && item.data.type === 'section'){
6969
if(index+1<items.length){
7070
const nextItem = items[index+1];
@@ -113,7 +113,6 @@ class Menu extends React.Component {
113113
isActive = focusIndex === i ? true : false;
114114
}
115115
if(c.data.type==='section'){
116-
// focusIndex++;
117116
return <DefaultSectionHeader data={c.data} key={'section_header_'+i}/>;
118117
}
119118
return <Item

components/SLDSLookup/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ class SLDSLookup extends React.Component {
191191
let numFocusable = this.getNumFocusableItems();
192192
let prevFocusIndex = this.state.focusIndex > 0 ? this.state.focusIndex - 1 : numFocusable;
193193
const filteredItem = this.refs.menu.getFilteredItemForIndex(prevFocusIndex);
194+
console.log('filteredItem', filteredItem);
194195
if(filteredItem && filteredItem.data.type === 'section'){
195-
prevFocusIndex--;
196+
prevFocusIndex === 0 ? prevFocusIndex = numFocusable : prevFocusIndex--;
196197
}
197198
this.setState({ focusIndex: prevFocusIndex});
198199
}

demo/code-snippets/LookupExamples3.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
onChange={function(newValue){console.log("New search term: ", newValue)}}
66
onSelect={function(item){console.log(item , " Selected")}}
77
options={[
8+
{type:'section', label:'SECTION 1'},
89
{label: "Paddy\"s Pub"},
910
{label: "Tyrell Corp"},
11+
{type:'section', label:'SECTION 2'},
1012
{label: "Paper St. Soap Company"},
1113
{label: "Nakatomi Investments"},
1214
{label: "Acme Landscaping"},
15+
{type:'section', label:'SECTION 3'},
1316
{label: "Acme Construction"}
1417
]}
1518
/>
19+

0 commit comments

Comments
 (0)