Skip to content

Revert "Add support for clicking TAB on input focus" #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/DayPickerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';

import DayPicker from './DayPicker';
import { getModifiersForDay } from './ModifiersUtils';
import { ESC, TAB } from './keys';
import { ESC } from './keys';

// When clicking on a day cell, overlay will be hidden after this timeout
export const HIDE_TIMEOUT = 100;
Expand Down Expand Up @@ -81,7 +81,6 @@ export default class DayPickerInput extends React.Component {
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onKeyUp: PropTypes.func,
onKeyDown: PropTypes.func,
};

static defaultProps = {
Expand Down Expand Up @@ -121,7 +120,6 @@ export default class DayPickerInput extends React.Component {
this.handleInputBlur = this.handleInputBlur.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
this.handleInputKeyUp = this.handleInputKeyUp.bind(this);
this.handleInputKeyDown = this.handleInputKeyDown.bind(this);
this.handleDayClick = this.handleDayClick.bind(this);
}

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

handleInputKeyDown(e) {
if (e.keyCode === TAB) {
this.clickedInside = true;
}
if (this.props.inputProps.onKeyDown) {
e.persist();
this.props.inputProps.onKeyDown(e);
}
}

handleInputKeyUp(e) {
// Hide the overlay if the ESC key is pressed
this.setState({ showOverlay: e.keyCode !== ESC });
Expand Down Expand Up @@ -465,7 +453,6 @@ export default class DayPickerInput extends React.Component {
onBlur={this.handleInputBlur}
onKeyUp={this.handleInputKeyUp}
onClick={this.handleInputClick}
onKeyDown={this.handleInputKeyDown}
/>
{this.state.showOverlay && this.renderOverlay()}
</div>
Expand Down
1 change: 0 additions & 1 deletion src/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export const DOWN = 40;
export const ENTER = 13;
export const SPACE = 32;
export const ESC = 27;
export const TAB = 9;
15 changes: 0 additions & 15 deletions test/daypickerinput/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,6 @@ describe('DayPickerInput', () => {
expect(onKeyUp).toHaveBeenCalledTimes(1);
});
});
describe('keydown', () => {
it('should not hide the overlay on TAB', () => {
const wrapper = mount(<DayPickerInput />);
wrapper.instance().showDayPicker();
wrapper.update();
wrapper.find('input').simulate('keydown', { keyCode: keys.TAB });
expect(wrapper.state('showOverlay')).toBe(true);
});
it('should call `onKeyDown` event handler', () => {
const onKeyDown = jest.fn();
const wrapper = mount(<DayPickerInput inputProps={{ onKeyDown }} />);
wrapper.find('input').simulate('keydown');
expect(onKeyDown).toHaveBeenCalledTimes(1);
});
});
describe('dayclick', () => {
it('should call `onDayClick` event handler', () => {
const onDayClick = jest.fn();
Expand Down