Merge pull request #4108 from matrix-org/jryans/a11y-editor-keyboard

Add shortcuts for beginning / end of composer
This commit is contained in:
J. Ryan Stinnett 2020-02-24 12:02:03 +00:00 committed by GitHub
commit c0c22ba7f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -392,6 +392,20 @@ export default class BasicMessageEditor extends React.Component {
} else if (event.key === Key.ENTER && (event.shiftKey || (IS_MAC && event.altKey))) { } else if (event.key === Key.ENTER && (event.shiftKey || (IS_MAC && event.altKey))) {
this._insertText("\n"); this._insertText("\n");
handled = true; handled = true;
// move selection to start of composer
} else if (modKey && event.key === Key.HOME) {
setSelection(this._editorRef, model, {
index: 0,
offset: 0,
});
handled = true;
// move selection to end of composer
} else if (modKey && event.key === Key.END) {
setSelection(this._editorRef, model, {
index: model.parts.length - 1,
offset: model.parts[model.parts.length - 1].text.length,
});
handled = true;
// autocomplete or enter to send below shouldn't have any modifier keys pressed. // autocomplete or enter to send below shouldn't have any modifier keys pressed.
} else { } else {
const metaOrAltPressed = event.metaKey || event.altKey; const metaOrAltPressed = event.metaKey || event.altKey;