Skip to content

Commit ee398dc

Browse files
committed
more cleanup
1 parent 573a226 commit ee398dc

File tree

2 files changed

+8
-45
lines changed

2 files changed

+8
-45
lines changed

components/SLDSMenuList/index.jsx

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const propTypes = {
2323
* If true, renders checkmark icon on the selected Menu Item.
2424
*/
2525
checkmark: React.PropTypes.bool,
26-
disabled: React.PropTypes.bool,
2726
label: React.PropTypes.string,
2827
/**
2928
* Custom element that overrides the default Menu Item component.
@@ -32,25 +31,14 @@ const propTypes = {
3231
/**
3332
* If true, component renders specifically to work inside Modal.
3433
*/
35-
modal: React.PropTypes.bool,
3634
onClick: React.PropTypes.func,
3735
onSelect: React.PropTypes.func,
3836
/**
3937
* Menu item data.
4038
*/
4139
options: React.PropTypes.array.isRequired,
42-
placeholder: React.PropTypes.string,
43-
required: React.PropTypes.bool,
44-
/**
45-
* Current selected item.
46-
*/
47-
value: React.PropTypes.node,
4840
};
4941
const defaultProps = {
50-
disabled: false,
51-
modal: true,
52-
required: false,
53-
placeholder: "Select an Option",
5442
checkmark: true
5543
};
5644

@@ -65,11 +53,12 @@ class SLDSMenuPicklist extends React.Component {
6553
isOpen: false,
6654
lastBlurredIndex: -1,
6755
lastBlurredTimeStamp: -1,
68-
selectedIndex: this.getIndexByValue(this.props.value),
56+
selectedIndex: this.props.selectedIndex,
6957
/* triggerId is the id of the element that triggers the Menu to open.
7058
* Need this for aria-labelledby on <ul> in Menu for accessibility. */
7159
triggerId: this.props.label ? this.props.label.replace(/\s+/g, '') + '_Button': 'Picklist_Button',
7260
};
61+
7362
}
7463

7564
componentWillUnmount(){
@@ -86,45 +75,22 @@ class SLDSMenuPicklist extends React.Component {
8675
this.handleClose();
8776
}
8877

89-
if(this.props.value !== prevProps.value ||
78+
if(this.props.selectedIndex !== prevProps.selectedIndex ||
9079
!isEqual(this.props.options, prevProps.options)){
91-
var newSelectedIndex = this.getIndexByValue(this.props.value);
92-
if (newSelectedIndex !== this.state.selectedIndex) {
93-
this.handleSelect(newSelectedIndex);
80+
if (this.props.selectedIndex !== this.state.selectedIndex) {
81+
this.handleSelect(this.props.selectedIndex);
9482
}
9583
}
9684
}
9785

98-
getIndexByValue(value){
99-
let foundIndex = -1;
100-
if(this.props.options && this.props.options.length){
101-
this.props.options.some((element, index, array)=>{
102-
if(element && element.value === value){
103-
foundIndex = index;
104-
return true;
105-
}
106-
return false;
107-
});
108-
}
109-
return foundIndex;
110-
}
111-
112-
getValueByIndex(index){
113-
const option = this.props.options[index];
114-
if(option){
115-
return this.props.options[index];
116-
}
117-
}
118-
11986
handleSelect(index) {
12087
this.setState({selectedIndex: index})
12188
if(this.props.onSelect){
122-
this.props.onSelect(this.getValueByIndex(index));
89+
this.props.onSelect(index);
12390
}
12491
}
12592

12693
handleClose() {
127-
console.log('!!! handleClose !!!');
12894
if(this.props.onCancel){
12995
this.props.onCancel();
13096
}

components/SLDSTimepicker/index.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,13 @@ module.exports = React.createClass({
179179

180180
getPopoverContent() {
181181
return <SLDSMenuList
182-
// checkmark={this.props.checkmark}
183-
// highlightedIndex={this.state.highlightedIndex}
182+
checkmark={false}
184183
itemRenderer={this.getListItemRenderer()}
185184
onCancel={this.handleCancel}
186185
onSelect={this.handleSelect}
187-
// onUpdateHighlighted={this.handleUpdateHighlighted}
188186
options={this.getOptions()}
189187
ref="list"
190-
// selectedIndex={this.state.selectedIndex}
191-
// triggerId={this.state.triggerId}
188+
selectedIndex={3}
192189
/>;
193190
},
194191

0 commit comments

Comments
 (0)