Skip to content

Commit 5da2ab8

Browse files
authored
Merge pull request #595 from gpbl/revert-588-tab_keydown_handling
Revert "Add support for clicking TAB on input focus"
2 parents c7f6658 + d15c836 commit 5da2ab8

File tree

3 files changed

+1
-30
lines changed

3 files changed

+1
-30
lines changed

src/DayPickerInput.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33

44
import DayPicker from './DayPicker';
55
import { getModifiersForDay } from './ModifiersUtils';
6-
import { ESC, TAB } from './keys';
6+
import { ESC } from './keys';
77

88
// When clicking on a day cell, overlay will be hidden after this timeout
99
export const HIDE_TIMEOUT = 100;
@@ -81,7 +81,6 @@ export default class DayPickerInput extends React.Component {
8181
onFocus: PropTypes.func,
8282
onBlur: PropTypes.func,
8383
onKeyUp: PropTypes.func,
84-
onKeyDown: PropTypes.func,
8584
};
8685

8786
static defaultProps = {
@@ -121,7 +120,6 @@ export default class DayPickerInput extends React.Component {
121120
this.handleInputBlur = this.handleInputBlur.bind(this);
122121
this.handleInputChange = this.handleInputChange.bind(this);
123122
this.handleInputKeyUp = this.handleInputKeyUp.bind(this);
124-
this.handleInputKeyDown = this.handleInputKeyDown.bind(this);
125123
this.handleDayClick = this.handleDayClick.bind(this);
126124
}
127125

@@ -336,16 +334,6 @@ export default class DayPickerInput extends React.Component {
336334
this.updateState(day, value);
337335
}
338336

339-
handleInputKeyDown(e) {
340-
if (e.keyCode === TAB) {
341-
this.clickedInside = true;
342-
}
343-
if (this.props.inputProps.onKeyDown) {
344-
e.persist();
345-
this.props.inputProps.onKeyDown(e);
346-
}
347-
}
348-
349337
handleInputKeyUp(e) {
350338
// Hide the overlay if the ESC key is pressed
351339
this.setState({ showOverlay: e.keyCode !== ESC });
@@ -465,7 +453,6 @@ export default class DayPickerInput extends React.Component {
465453
onBlur={this.handleInputBlur}
466454
onKeyUp={this.handleInputKeyUp}
467455
onClick={this.handleInputClick}
468-
onKeyDown={this.handleInputKeyDown}
469456
/>
470457
{this.state.showOverlay && this.renderOverlay()}
471458
</div>

src/keys.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ export const DOWN = 40;
55
export const ENTER = 13;
66
export const SPACE = 32;
77
export const ESC = 27;
8-
export const TAB = 9;

test/daypickerinput/events.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,6 @@ describe('DayPickerInput', () => {
154154
expect(onKeyUp).toHaveBeenCalledTimes(1);
155155
});
156156
});
157-
describe('keydown', () => {
158-
it('should not hide the overlay on TAB', () => {
159-
const wrapper = mount(<DayPickerInput />);
160-
wrapper.instance().showDayPicker();
161-
wrapper.update();
162-
wrapper.find('input').simulate('keydown', { keyCode: keys.TAB });
163-
expect(wrapper.state('showOverlay')).toBe(true);
164-
});
165-
it('should call `onKeyDown` event handler', () => {
166-
const onKeyDown = jest.fn();
167-
const wrapper = mount(<DayPickerInput inputProps={{ onKeyDown }} />);
168-
wrapper.find('input').simulate('keydown');
169-
expect(onKeyDown).toHaveBeenCalledTimes(1);
170-
});
171-
});
172157
describe('dayclick', () => {
173158
it('should call `onDayClick` event handler', () => {
174159
const onDayClick = jest.fn();

0 commit comments

Comments
 (0)