Do not jump to next field when pressing Tab during IME composition #1531

This commit is contained in:
Ben Gotow 2019-07-01 13:41:18 -05:00
parent a6a3b5d23a
commit 2508797ff1

View file

@ -9,16 +9,24 @@ import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
let compositionActive = false;
document.addEventListener('compositionstart', () => {
compositionActive = true;
});
document.addEventListener('compositionend', () => {
compositionActive = false;
});
export class TabGroupRegion extends React.Component<React.HTMLProps<HTMLDivElement>> {
static childContextTypes = { parentTabGroup: PropTypes.object };
_onKeyDown = event => {
if (event.key === 'Tab' && !event.defaultPrevented) {
const dir = event.shiftKey ? -1 : 1;
this.shiftFocus(dir);
event.preventDefault();
event.stopPropagation();
}
if (event.key !== 'Tab' || event.defaultPrevented) return;
if (compositionActive) return;
const dir = event.shiftKey ? -1 : 1;
this.shiftFocus(dir);
event.preventDefault();
event.stopPropagation();
};
shiftFocus = dir => {