mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Update composer to correctly call countCompletions and moveSelection
This commit is contained in:
parent
bb133c1ebc
commit
97d4d1b73a
@ -673,23 +673,23 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
this.direction = '';
|
this.direction = '';
|
||||||
|
|
||||||
// Navigate autocomplete list with arrow keys
|
// Navigate autocomplete list with arrow keys
|
||||||
if (this.autocomplete.state.completionList.length > 0) {
|
if (this.autocomplete.countCompletions() > 0) {
|
||||||
if (!(ev.ctrlKey || ev.shiftKey || ev.altKey || ev.metaKey)) {
|
if (!(ev.ctrlKey || ev.shiftKey || ev.altKey || ev.metaKey)) {
|
||||||
switch (ev.keyCode) {
|
switch (ev.keyCode) {
|
||||||
case KeyCode.LEFT:
|
case KeyCode.LEFT:
|
||||||
this.moveAutocompleteSelection(true);
|
this.autocomplete.moveSelection(-1);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
case KeyCode.RIGHT:
|
case KeyCode.RIGHT:
|
||||||
this.moveAutocompleteSelection(false);
|
this.autocomplete.moveSelection(+1);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
case KeyCode.UP:
|
case KeyCode.UP:
|
||||||
this.moveAutocompleteSelection(true);
|
this.autocomplete.moveSelection(-1);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
case KeyCode.DOWN:
|
case KeyCode.DOWN:
|
||||||
this.moveAutocompleteSelection(false);
|
this.autocomplete.moveSelection(+1);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1225,23 +1225,19 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
someCompletions: null,
|
someCompletions: null,
|
||||||
});
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.autocomplete.state.completionList.length === 0) {
|
if (this.autocomplete.countCompletions() === 0) {
|
||||||
// Force completions to show for the text currently entered
|
// Force completions to show for the text currently entered
|
||||||
const completionCount = await this.autocomplete.forceComplete();
|
const completionCount = await this.autocomplete.forceComplete();
|
||||||
this.setState({
|
this.setState({
|
||||||
someCompletions: completionCount > 0,
|
someCompletions: completionCount > 0,
|
||||||
});
|
});
|
||||||
// Select the first item by moving "down"
|
// Select the first item by moving "down"
|
||||||
await this.moveAutocompleteSelection(false);
|
await this.autocomplete.moveSelection(+1);
|
||||||
} else {
|
} else {
|
||||||
await this.moveAutocompleteSelection(e.shiftKey);
|
await this.autocomplete.moveSelection(e.shiftKey ? -1 : +1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
moveAutocompleteSelection = (up) => {
|
|
||||||
up ? this.autocomplete.onUpArrow() : this.autocomplete.onDownArrow();
|
|
||||||
};
|
|
||||||
|
|
||||||
onEscape = async (e) => {
|
onEscape = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.autocomplete) {
|
if (this.autocomplete) {
|
||||||
|
Loading…
Reference in New Issue
Block a user