Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public pressEsc() {
simulate.keyDown(this.nativeInput, {keyCode: KeyCodes.esc});
}
await waitForDom(() => {
const input = select('NATIVE_INPUT_NUMBER') as HTMLInputElement;
simulateKeyInput(input, '1');
simulateKeyInput(input, '2');
simulateKeyInput(input, '3');
simulate.keyDown(input, {keyCode: KeyCodes.esc});
expect(onChange).not.to.have.been.called;
expect(input).to.have.value(String(initialValue));
});
});
private handleInputKeyDown: React.KeyboardEventHandler = e => {
switch (e.keyCode) {
case KeyCodes.up:
this.stepValue(Direction.Increase, e.shiftKey ? 10 : 1);
e.preventDefault();
break;
case KeyCodes.down:
this.stepValue(Direction.Decrease, e.shiftKey ? 10 : 1);
e.preventDefault();
break;
case KeyCodes.enter:
this.commit(this.state.value);
e.preventDefault();
break;
case KeyCodes.esc:
this.revert();
e.preventDefault();
break;
}
}
addBlurEventMethod = () => {
this.addBlurEvent.setConfig({
addListener: this.state.showList,
clickExcludeElm: this.rootElm,
blurCallback: () => {
this.setState({
showList: false
});
},
blurKeyCodes: [codes.esc]
});
}
addBlurEventMethod = () => {
const { pickerItemHeight } = this.props;
scrollToYEasing(this.monthListView.rootElm, this.monthIndex * pickerItemHeight, 0.1);
scrollToYEasing(this.dateListView.rootElm, this.dateIndex * pickerItemHeight, 0.1);
scrollToYEasing(this.yearListView.rootElm, this.yearIndex * pickerItemHeight, 0.1);
this.addBlurEvent.setConfig({
addListener: this.state.showPicker,
clickExcludeElm: this.rootElm,
blurCallback: () => {
this.setState({
showPicker: false
});
},
blurKeyCodes: [codes.esc]
});
}
addBlurEventMethod = () => {
this.addBlurEvent.setConfig({
addListener: this.state.showCalendarView,
clickExcludeElm: this.rootElm,
blurCallback: () => {
this.setState({
showCalendarView: false
});
},
blurKeyCodes: [codes.esc]
});
}
addBlurEventMethod = () => {
this.addBlurEvent.setConfig({
addListener: this.state.currExpanded,
clickExcludeElm: this.rootElm,
blurCallback: () => {
this.setState({
currExpanded: false
});
},
blurKeyCodes: [codes.esc]
});
}
addBlurEventMethod = () => {
const { clickExcludeElms } = this.props;
this.addBlurEvent.setConfig({
addListener: this.state.expanded,
clickExcludeElm: clickExcludeElms ? [...clickExcludeElms, this.rootElm] : this.rootElm,
blurCallback: () => {
this.setState({
expanded: false
}, this.props.onClosePane);
},
blurKeyCodes: [codes.esc]
});
}
addBlurEventMethod = () => {
this.addBlurEvent.setConfig({
addListener: this.state.expanded,
clickExcludeElm: this.rootElm,
blurCallback: () => {
this.setState({
expanded: false
});
},
blurKeyCodes: [codes.esc]
});
}