Skip to content

Commit 76bbab9

Browse files
committed
lookup footer refactoring
1 parent fbefe38 commit 76bbab9

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

components/SLDSLookup/Menu/DefaultFooter/index.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import React, { Component } from 'react';
1111
import {Icon} from "../../../SLDSIcons";
12+
import { EventUtil } from '../../../utils';
13+
1214

1315
class DefaultFooter extends React.Component {
1416
constructor(props) {
@@ -19,16 +21,20 @@ class DefaultFooter extends React.Component {
1921
if(nextProps.isActive !== this.props.isActive && nextProps.isActive === true) this.props.setFocus(this.props.id);
2022
}
2123

22-
footerClick(){
24+
handleClick(){
2325
console.log('=====> Lookup Footer Clicked');
2426
}
2527

28+
handleMouseDown(event) {
29+
EventUtil.trapImmediate(event);
30+
}
31+
2632
render(){
2733
let className = 'slds-button';
2834
if(this.props.isActive) className += ' slds-theme--shade'
2935

3036
return (
31-
<div className="slds-lookup__item" onClick={this.footerClick}>
37+
<div className="slds-lookup__item" onClick={this.handleClick.bind(this)} onMouseDown={this.handleMouseDown.bind(this)}>
3238
<button id='newItem' tabIndex="-1" className={className}>
3339
<Icon name='add' category="utility" size="x-small" className="slds-icon-text-default" />
3440
{'New ' + this.props.type}

components/SLDSLookup/index.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ class SLDSLookup extends React.Component {
159159
React.findDOMNode(this.refs.header).click();
160160
}
161161
//If the focus is on the last fixed Action Item in Menu, click it
162-
else if(this.props.footer && this.state.focusIndex === (this.state.listLength + 1)){
163-
document.getElementById('menuContainer').lastChild.children[0].click();
162+
else if(this.refs.footer && this.state.focusIndex === (this.state.listLength + 1)){
163+
React.findDOMNode(this.refs.footer).click();
164+
// document.getElementById('menuContainer').lastChild.children[0].click();
164165
}
165166
//If not, then select menu item
166167
else{
@@ -202,6 +203,15 @@ class SLDSLookup extends React.Component {
202203
}
203204
}
204205

206+
getFooter () {
207+
const Footer = this.props.footerRenderer;
208+
return <Footer ref='footer' {... this.props}
209+
focusIndex={this.state.focusIndex}
210+
listLength={this.state.listLength}
211+
onClose={this.handleClose.bind(this)}
212+
/>;
213+
}
214+
205215
//=================================================
206216
// Rendering Things
207217
renderMenuContent(){
@@ -218,7 +228,7 @@ class SLDSLookup extends React.Component {
218228
setFocus={this.setFocus.bind(this)}
219229
onSelect={this.selectItem.bind(this)}
220230
header={this.getHeader()}
221-
footer={this.props.footer}
231+
footer={this.getFooter()}
222232
/>;
223233
}
224234
}

demo/pages/HomePage/LookupBaseSection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports = React.createClass( {
7070
label="Account"
7171
type="account"
7272
headerRenderer={SLDSLookup.DefaultHeader}
73-
footer={this.getFooter()}
73+
footerRenderer={SLDSLookup.DefaultFooter}
7474
onChange={this.onChange}
7575
onItemSelect={this.selectItem}
7676
/>

0 commit comments

Comments
 (0)