mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-04 07:10:06 +08:00
Do not jump to next field when pressing Tab during IME composition #1531
This commit is contained in:
parent
a6a3b5d23a
commit
2508797ff1
1 changed files with 14 additions and 6 deletions
|
@ -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 => {
|
||||
|
|
Loading…
Reference in a new issue