Open calendar when clicking on input element
Before it would just open the calendar on focus, and this would cause
problems for users when they close the calendar and want to open it
again. Before this change the user would have to trigger an onBlur by
clicking somewhere else before triggering onFocus again to open the
calendar again.
| | |
| | | children = []; |
| | | |
| | | if ( this.props.input ) { |
| | | children = [ React.createElement('input', assign({ |
| | | children = [ React.createElement( 'input', assign({ |
| | | key: 'i', |
| | | type: 'text', |
| | | className: 'form-control', |
| | | onClick: this.openCalendar, |
| | | onFocus: this.openCalendar, |
| | | onChange: this.onInputChange, |
| | | onKeyDown: this.onInputKey, |
| | |
| | | if ( this.state.open ) |
| | | className += ' rdtOpen'; |
| | | |
| | | return React.createElement('div', {className: className}, children.concat( |
| | | React.createElement('div', |
| | | return React.createElement( 'div', { className: className }, children.concat( |
| | | React.createElement( 'div', |
| | | { key: 'dt', className: 'rdtPicker' }, |
| | | React.createElement( CalendarContainer, {view: this.state.currentView, viewProps: this.getComponentProps(), onClickOutside: this.handleClickOutside }) |
| | | React.createElement( CalendarContainer, { view: this.state.currentView, viewProps: this.getComponentProps(), onClickOutside: this.handleClickOutside }) |
| | | ) |
| | | )); |
| | | } |
| | |
| | | | **onViewModeChange** | `function` | empty function | Callback trigger when the view mode changes. The callback receives the selected view mode string (`years`, `months`, `days` or `time`) as only parameter.| |
| | | | **viewMode** | `string` or `number` | `'days'` | The default view to display when the picker is shown (`'years'`, `'months'`, `'days'`, `'time'`). | |
| | | | **className** | `string` or `string array` | `''` | Extra class name for the outermost markup element. | |
| | | | **inputProps** | `object` | `undefined` | Defines additional attributes for the input element of the component. For example: `placeholder`, `disabled`, `required`, `name` and `className` (`className` *sets* the class attribute for the input element). | |
| | | | **inputProps** | `object` | `undefined` | Defines additional attributes for the input element of the component. For example: `onClick`, `placeholder`, `disabled`, `required`, `name` and `className` (`className` *sets* the class attribute for the input element). | |
| | | | **isValidDate** | `function` | `() => true` | Define the dates that can be selected. The function receives `(currentDate, selectedDate)` and shall return a `true` or `false` whether the `currentDate` is valid or not. See [selectable dates](#selectable-dates).| |
| | | | **renderDay** | `function` | `DOM.td(day)` | Customize the way that the days are shown in the daypicker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, and must return a React component. See [appearance customization](#customize-the-appearance). | |
| | | | **renderMonth** | `function` | `DOM.td(month)` | Customize the way that the months are shown in the monthpicker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, the `month` and the `year` to be shown, and must return a React component. See [appearance customization](#customize-the-appearance). | |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="arbitrary-className" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | className="form-control" |
| | | disabled={true} |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | className="form-control" |
| | | name="arbitrary-name" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | placeholder="arbitrary-placeholder" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | required={true} |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | <input |
| | | className="form-control" |
| | | onChange={[Function]} |
| | | onClick={[Function]} |
| | | onFocus={[Function]} |
| | | onKeyDown={[Function]} |
| | | type="text" |
| | |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('opens picker when clicking on input', () => { |
| | | const component = utils.createDatetime(); |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | component.find('.form-control').simulate('click'); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('sets CSS class on selected item (day)', () => { |
| | | const component = utils.createDatetime({ viewMode: 'days' }); |
| | | utils.openDatepicker(component); |