Make everything use the KeyBindingManager
(#7907)
This commit is contained in:
parent
5f8441216c
commit
df591ee835
37 changed files with 529 additions and 277 deletions
|
@ -17,7 +17,8 @@ limitations under the License.
|
|||
|
||||
import React, { createRef } from 'react';
|
||||
|
||||
import { Key } from "../../../Keyboard";
|
||||
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
||||
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
|
||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||
|
||||
enum Phases {
|
||||
|
@ -124,9 +125,12 @@ export default class EditableText extends React.Component<IProps, IState> {
|
|||
this.showPlaceholder(false);
|
||||
}
|
||||
|
||||
if (ev.key === Key.ENTER) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
const action = getKeyBindingsManager().getAccessibilityAction(ev);
|
||||
switch (action) {
|
||||
case KeyBindingAction.Enter:
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
break;
|
||||
}
|
||||
|
||||
// console.log("keyDown: textContent=" + ev.target.textContent + ", value=" + this.value + ", placeholder=" + this.placeholder);
|
||||
|
@ -141,10 +145,14 @@ export default class EditableText extends React.Component<IProps, IState> {
|
|||
this.value = (ev.target as HTMLDivElement).textContent;
|
||||
}
|
||||
|
||||
if (ev.key === Key.ENTER) {
|
||||
this.onFinish(ev);
|
||||
} else if (ev.key === Key.ESCAPE) {
|
||||
this.cancelEdit();
|
||||
const action = getKeyBindingsManager().getAccessibilityAction(ev);
|
||||
switch (action) {
|
||||
case KeyBindingAction.Escape:
|
||||
this.cancelEdit();
|
||||
break;
|
||||
case KeyBindingAction.Enter:
|
||||
this.onFinish(ev);
|
||||
break;
|
||||
}
|
||||
|
||||
// console.log("keyUp: textContent=" + ev.target.textContent + ", value=" + this.value + ", placeholder=" + this.placeholder);
|
||||
|
@ -179,7 +187,8 @@ export default class EditableText extends React.Component<IProps, IState> {
|
|||
): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
const submit = ("key" in ev && ev.key === Key.ENTER) || shouldSubmit;
|
||||
const action = getKeyBindingsManager().getAccessibilityAction(ev as React.KeyboardEvent);
|
||||
const submit = action === KeyBindingAction.Enter || shouldSubmit;
|
||||
this.setState({
|
||||
phase: Phases.Display,
|
||||
}, () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue