Skip to content

Commit 73e5304

Browse files
committed
modal PicklistBase prop
1 parent 6881ed1 commit 73e5304

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

components/SLDSPicklistBase/index.jsx

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Neither the name of salesforce.com, inc. nor the names of its contributors may b
77
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88
*/
99

10-
import React, { Component } from 'react';
10+
'use strict';
11+
12+
import React from 'react';
1113
import SLDSPopover from '../SLDSPopover';
1214
import List from './list';
1315

@@ -28,6 +30,7 @@ module.exports = React.createClass( {
2830
value: null,
2931
options: [],
3032
initialFocus: false,
33+
modal: false,
3134
onClick () {
3235
console.log('onClick should be defined');
3336
},
@@ -143,15 +146,8 @@ module.exports = React.createClass( {
143146
this.setFocus();
144147
},
145148

146-
getPopover() {
147-
return (
148-
!this.props.disabled && this.state.isOpen?
149-
<div
150-
ref="popover"
151-
className="slds-dropdown slds-dropdown--left slds-dropdown--small slds-dropdown--menu"
152-
targetElement={this.refs.button}
153-
style={{maxHeight:'20em'}}>
154-
<List
149+
getPopoverContent() {
150+
return <List
155151
ref='list'
156152
options={this.props.options}
157153
label={this.props.label}
@@ -162,11 +158,30 @@ module.exports = React.createClass( {
162158
onListBlur={this.handleListBlur}
163159
onListItemBlur={this.handleListItemBlur}
164160
onCancel={this.handleCancel}
165-
theme={this.props.theme} />
161+
theme={this.props.theme} />;
162+
},
163+
164+
getSimplePopover() {
165+
return (
166+
!this.props.disabled && this.state.isOpen?
167+
<div
168+
ref="popover"
169+
className="slds-dropdown slds-dropdown--left slds-dropdown--small slds-dropdown--menu"
170+
targetElement={this.refs.button}
171+
style={{maxHeight:'20em'}}>
172+
{this.getPopoverContent()}
166173
</div>:null
167174
);
168175
},
169176

177+
getModalPopover() {
178+
return (
179+
!this.props.disabled && this.state.isOpen?<SLDSPopover className='slds-dropdown' targetElement={this.refs.date} onClose={this.handleClose}>
180+
{this.getPopoverContent()}
181+
</SLDSPopover>:null
182+
);
183+
},
184+
170185
getPlaceholder() {
171186
const option = this.props.options[this.state.selectedIndex];
172187
return (option && option.label)?option.label:this.props.placeholder;
@@ -200,7 +215,7 @@ module.exports = React.createClass( {
200215
<Icon name="down" category="utility" />
201216
</button>
202217

203-
{this.getPopover()}
218+
{this.props.modal?this.getModalPopover():this.getSimplePopover()}
204219
</form>
205220

206221
</div>

demo/pages/HomePage.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,18 @@ export default class HomePage extends Component {
8585
{label:'B Option',value:'B0'},
8686
{label:'C Option',value:'C0'},
8787
{label:'D Option',value:'D0'},
88+
{label:'E Option',value:'E0'},
89+
{label:'A1 Option',value:'A1'},
90+
{label:'B2 Option',value:'B1'},
91+
{label:'C2 Option',value:'C1'},
92+
{label:'D2 Option',value:'D1'},
93+
{label:'E2 Option',value:'E1'},
94+
95+
8896
]}
8997
value='C0'
9098
label="Contacts"
99+
modal={true}
91100
placeholder = "Select a contact" />
92101
</div>
93102

0 commit comments

Comments
 (0)