Skip to content

Commit

Permalink
Merge pull request mui#3060 from andrejunges/master
Browse files Browse the repository at this point in the history
[DatePicker] Added disabled property and example
  • Loading branch information
oliviertassinari committed Jan 29, 2016
2 parents 528aedf + b24c583 commit f0ebb90
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const DatePickerExampleSimple = () => (
<div>
<DatePicker hintText="Portrait Dialog" />
<DatePicker hintText="Landscape Dialog" mode="landscape" />
<DatePicker hintText="Dialog Disabled" disabled={true} />
</div>
);

Expand Down
3 changes: 2 additions & 1 deletion docs/src/app/components/pages/components/DatePicker/Page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import datePickerExampleInternationalCode from '!raw!./ExampleInternational';
import datePickerReadmeText from './README';

const descriptions = {
simple: 'The Date Picker defaults to a portrait dialog. The `mode` property can be set to `landscape`.',
simple: 'The Date Picker defaults to a portrait dialog. The `mode` property can be set to `landscape`. You can ' +
'also disable the Dialog passing `true` to the `disabled` property.',
inline: 'Inline Date Pickers are displayed below the input, rather than as a modal dialog. ',
ranged: 'This example allows you to set a date range, and to toggle `autoOk`, and `disableYearSelection`.',
controlled: '`DatePicker` can be implemented as a controlled input, where `value` is handled by state in the ' +
Expand Down
13 changes: 10 additions & 3 deletions src/date-picker/date-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const DatePicker = React.createClass({
*/
disableYearSelection: React.PropTypes.bool,

/**
* Disables the DatePicker.
*/
disabled: React.PropTypes.bool,

/**
* Used to change the first day of week. It drastically varies from
* Saturday to Monday (could even be Friday) between different locales.
Expand Down Expand Up @@ -165,6 +170,7 @@ const DatePicker = React.createClass({
disableYearSelection: false,
style: {},
firstDayOfWeek: 0,
disabled: false,
};
},

Expand Down Expand Up @@ -248,9 +254,10 @@ const DatePicker = React.createClass({
_handleInputTouchTap: function _handleInputTouchTap(event) {
if (this.props.onTouchTap) this.props.onTouchTap(event);

setTimeout(() => {
this.openDialog();
}, 0);
if (!this.props.disabled)
setTimeout(() => {
this.openDialog();
}, 0);
},

_handleWindowKeyUp() {
Expand Down

0 comments on commit f0ebb90

Please sign in to comment.