Skip to content

Commit 5f8b29e

Browse files
committed
Allow flippable prop for DatePicker and TimePicker
1 parent 0b893da commit 5f8b29e

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

components/date-picker/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import {KEYS,EventUtil} from '../../utilities';
2020
const displayName = 'Datepicker';
2121
const propTypes = {
2222
abbrWeekDayLabels: React.PropTypes.array,
23+
/**
24+
* If true, allows popover to appear above input field based on available space with scroll position.
25+
*/
26+
flippable: React.PropTypes.bool,
2327
/**
2428
* Date formatting function
2529
*/
@@ -45,6 +49,7 @@ const propTypes = {
4549
};
4650
const defaultProps = {
4751
abbrWeekDayLabels: ['S','M','T','W','T','F','S'],
52+
flippable: true,
4853
formatter (date) {
4954
if(date){
5055
return (date.getMonth()+1) +
@@ -142,7 +147,7 @@ module.exports = React.createClass({
142147
popover() {
143148
if(this.state && this.state.isOpen){
144149
const date = this.state.strValue?this.parseDate(this.state.strValue):this.state.value;
145-
return <Popover className='slds-dropdown' targetElement={this.refs.date} onClose={this.handleClose}>
150+
return <Popover className='slds-dropdown' flippable={this.props.flippable} targetElement={this.refs.date} onClose={this.handleClose}>
146151
<DatePicker
147152
onChange={this.handleChange}
148153
selected={this.state.selected}

components/time-picker/index.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import {KEYS,EventUtil} from '../../utilities';
2121
const displayName = 'Timepicker';
2222
const propTypes = {
2323
constrainToScrollParent: React.PropTypes.bool,
24+
/**
25+
* If true, allows dropdown to appear above input field based on available space with scroll position.
26+
*/
27+
flippable: React.PropTypes.bool,
2428

2529
/**
2630
* Time formatting function
@@ -46,6 +50,7 @@ const propTypes = {
4650

4751
};
4852
const defaultProps = {
53+
flippable: true,
4954
formatter (date) {
5055
if(date){
5156
return date.toLocaleTimeString(navigator.language, {hour: '2-digit', minute:'2-digit'});
@@ -200,12 +205,12 @@ module.exports = React.createClass({
200205
return (
201206
!this.props.disabled && this.state.isOpen?
202207
<Popover
203-
className="slds-dropdown slds-dropdown--left "
208+
className="slds-dropdown slds-dropdown--left"
204209
closeOnTabKey={true}
205210
constrainToScrollParent={this.props.constrainToScrollParent}
206211
inheritTargetWidth={this.props.inheritTargetWidth}
207212
dropClass="slds-picklist"
208-
flippable={true}
213+
flippable={this.props.flippable}
209214
onClose={this.handleCancel.bind(this)}
210215
targetElement={this.refs.triggerbutton}>
211216
{this.getPopoverContent()}

stories/date-picker/index.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ const getDatepicker = props => (
1010
<Datepicker {...props} />
1111
);
1212

13-
const handleDateChange = (date) => {
14-
console.log('>>> onDateChange ', date);
15-
}
16-
1713
storiesOf(DATE_PICKER, module)
1814
.addDecorator(getStory => <div className="slds-p-around--medium">{getStory()}</div>)
19-
.add('Base', () => getDatepicker({ onDateChange: handleDateChange }))
15+
.add('Base', () => getDatepicker({ onDateChange: action('onDateChange') }))
2016

stories/time-picker/index.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ const getTimepicker = props => (
1010
<Timepicker {...props} />
1111
);
1212

13-
const handleDateChange = (date, inputStr) => {
14-
console.log('>>> onDateChange ', date, ' inputStr: ',inputStr);
15-
}
16-
1713
storiesOf(TIME_PICKER, module)
1814
.addDecorator(getStory => <div className="slds-p-around--medium">{getStory()}</div>)
19-
.add('Base', () => getTimepicker({ stepInMinutes: 30, onDateChange: handleDateChange }))
15+
.add('Base', () => getTimepicker({ stepInMinutes: 30, onDateChange: action('onDateChange') }))
2016

0 commit comments

Comments
 (0)