Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (event.keyCode === KeyCode.KEY_UP) {
stateValue = TimeUtil.incrementSecond(stateValue);
}
if (event.keyCode === KeyCode.KEY_DOWN) {
stateValue = TimeUtil.decrementSecond(stateValue);
}
if (previousStateValue !== stateValue) {
this.handleValueChange(event, TimeUtil.inputType.SECOND, stateValue, this.state.meridiem);
}
if (event.keyCode === KeyCode.KEY_LEFT
|| event.keyCode === KeyCode.KEY_DELETE
|| event.keyCode === KeyCode.KEY_BACK_SPACE) {
this.focusMinuteFromSecond(event);
}
}
handleMonthKeyDown(event) {
const displayFormat = DateInputUtil.computedDisplayFormat(this.props.displayFormat, this.props.intl.locale);
if (event.keyCode === KeyCode.KEY_BACK_SPACE || event.keyCode === KeyCode.KEY_DELETE) {
this.handleValueChange(event, DateInputUtil.inputType.MONTH, '');
if (displayFormat === 'day-month-year' && event.target.value === '') {
this.focusDay(event);
}
}
if (event.keyCode === KeyCode.KEY_SPACE || event.keyCode === KeyCode.KEY_UP || event.keyCode === KeyCode.KEY_DOWN) {
this.setState({ isPlaceholderColored: false });
}
}
handleKeyDown(event) {
const {
children, intl, onDeselect, value,
} = this.props;
const { keyCode, target } = event;
if (keyCode === KeyCode.KEY_SPACE && target !== this.input) {
event.preventDefault();
this.openDropdown(event);
} else if (keyCode === KeyCode.KEY_UP || keyCode === KeyCode.KEY_DOWN) {
event.preventDefault();
this.openDropdown(event);
} else if (keyCode === KeyCode.KEY_BACK_SPACE && !this.state.searchValue && value.length > 0) {
const lastOptionValue = value[value.length - 1];
const lastOption = MenuUtil.findByValue(children, lastOptionValue);
const lastOptionDisplay = lastOption ? lastOption.props.display : lastOptionValue;
if (this.visuallyHiddenComponent && this.visuallyHiddenComponent.current) {
this.visuallyHiddenComponent.current.innerText = intl.formatMessage({ id: 'Terra.form.select.unselectedText' }, { text: lastOptionDisplay });
}
if (onDeselect) {
onDeselect(lastOptionValue);
}
} else if (keyCode === KeyCode.KEY_ESCAPE) {
this.closeDropdown();
}
}
handleKeyDown(event) {
const {
children, intl, onDeselect, value,
} = this.props;
const { keyCode, target } = event;
if (keyCode === KeyCode.KEY_SPACE && target !== this.input) {
event.preventDefault();
this.openDropdown(event);
} else if (keyCode === KeyCode.KEY_UP || keyCode === KeyCode.KEY_DOWN) {
event.preventDefault();
this.openDropdown(event);
} else if (keyCode === KeyCode.KEY_BACK_SPACE && !this.state.searchValue && value.length > 0) {
const lastOptionValue = value[value.length - 1];
const lastOption = MenuUtil.findByValue(children, lastOptionValue);
const lastOptionDisplay = lastOption ? lastOption.props.display : lastOptionValue;
if (this.visuallyHiddenComponent && this.visuallyHiddenComponent.current) {
this.visuallyHiddenComponent.current.innerText = intl.formatMessage({ id: 'Terra.form.select.unselectedText' }, { text: lastOptionDisplay });
}
if (onDeselect) {
onDeselect(lastOptionValue);
}
} else if (keyCode === KeyCode.KEY_ESCAPE) {
this.closeDropdown();
}
}