Skip to content

Commit 48dd601

Browse files
committed
Merge pull request #5 from sfdc-matrix/picklistModalIssue
Fix Picklist in Modal + EventUtil for Testing
2 parents 7ef1621 + 8e3712d commit 48dd601

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

components/SLDSPicklistBase/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,12 @@ module.exports = React.createClass( {
261261
this.setState({isOpen:false})
262262
}
263263
}
264-
}
264+
/* resolve a double click issue with the modal */
265+
} else if (this.props.modal && this.state.isFocused && prevState.isFocused) {
266+
if (!this.state.isOpen) {
267+
this.setState({isOpen : true});
268+
}
269+
}
265270

266271

267272
if(this.props.value !== prevProps.value){

components/SLDSPicklistBase/list-item.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module.exports = React.createClass({
9090
this.props.onMoveFocus(-1);
9191
}
9292
}
93-
else if(event.keyCode === KEYS.ENTER ||
93+
else if(event.keyCode === KEYS.ENTER ||
9494
event.keyCode === KEYS.SPACE ){
9595
EventUtil.trapEvent(event);
9696
if(this.props.onSelect){
@@ -116,7 +116,9 @@ module.exports = React.createClass({
116116
},
117117

118118
handleBlur(e) {
119-
if(this.props.onBlur){
119+
if (this.props.onBlur &&
120+
this.refs.link.getDOMNode() !== e.target) {
121+
120122
this.props.onBlur(this.props.index, e.relatedTarget);
121123
}
122124
},
@@ -130,15 +132,15 @@ module.exports = React.createClass({
130132

131133
render () {
132134
return (
133-
<li
135+
<li
134136

135137
className={"slds-dropdown__item slds-has-icon slds-has-icon--left slds-theme--"+this.props.theme}
136138
onMouseDown={this.handleMouseDown}
137139
tabIndex={-1}>
138140
<a id={'menu-0-'+this.props.index}
139141
href=''
140142
ref='link'
141-
className='slds-truncate'
143+
className='slds-truncate'
142144
onClick={this.handleClick}
143145
onMouseDown={this.handleMouseDown}
144146
onKeyDown={this.handleKeyDown}

components/utils/EventUtil.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ const EventUtil = {
1616
trapEvent(event){
1717
event.preventDefault();
1818
event.stopPropagation();
19-
if(event.nativeEvent){
19+
20+
if(event.nativeEvent && event.nativeEvent.preventDefault){
2021
event.nativeEvent.preventDefault();
22+
}
23+
24+
if (event.nativeEvent && event.nativeEvent.stopPropagation){
2125
event.nativeEvent.stopPropagation();
2226
}
2327
},
@@ -27,12 +31,12 @@ const EventUtil = {
2731
},
2832

2933
trapImmediate(event){
30-
if(event.nativeEvent){
34+
if(event.nativeEvent && event.nativeEvent.stopImmediatePropagation){
3135
event.nativeEvent.stopImmediatePropagation();
3236
}
3337
EventUtil.trap(event);
3438
}
3539

3640
};
3741

38-
module.exports = EventUtil;
42+
module.exports = EventUtil;

0 commit comments

Comments
 (0)