mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
Merge pull request #1188 from matrix-org/luke/feature-rte-visual-bell
Add visual feedback for when there are no completions available
This commit is contained in:
commit
7f1d8e3c90
2 changed files with 12 additions and 2 deletions
|
@ -177,7 +177,7 @@ export default class Autocomplete extends React.Component {
|
||||||
hide: false,
|
hide: false,
|
||||||
}, () => {
|
}, () => {
|
||||||
this.complete(this.props.query, this.props.selection).then(() => {
|
this.complete(this.props.query, this.props.selection).then(() => {
|
||||||
done.resolve();
|
done.resolve(this.countCompletions());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
|
|
|
@ -138,6 +138,9 @@ export default class MessageComposerInput extends React.Component {
|
||||||
// the virtual state "above" the history stack, the message currently being composed that
|
// the virtual state "above" the history stack, the message currently being composed that
|
||||||
// we want to persist whilst browsing history
|
// we want to persist whilst browsing history
|
||||||
currentlyComposedEditorState: null,
|
currentlyComposedEditorState: null,
|
||||||
|
|
||||||
|
// whether there were any completions
|
||||||
|
someCompletions: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// bit of a hack, but we need to do this here since createEditorState needs isRichtextEnabled
|
// bit of a hack, but we need to do this here since createEditorState needs isRichtextEnabled
|
||||||
|
@ -706,10 +709,16 @@ export default class MessageComposerInput extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
onTab = async (e) => {
|
onTab = async (e) => {
|
||||||
|
this.setState({
|
||||||
|
someCompletions: null,
|
||||||
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.autocomplete.state.completionList.length === 0) {
|
if (this.autocomplete.state.completionList.length === 0) {
|
||||||
// Force completions to show for the text currently entered
|
// Force completions to show for the text currently entered
|
||||||
await this.autocomplete.forceComplete();
|
const completionCount = await this.autocomplete.forceComplete();
|
||||||
|
this.setState({
|
||||||
|
someCompletions: completionCount > 0,
|
||||||
|
});
|
||||||
// Select the first item by moving "down"
|
// Select the first item by moving "down"
|
||||||
await this.moveAutocompleteSelection(false);
|
await this.moveAutocompleteSelection(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -830,6 +839,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
|
|
||||||
const className = classNames('mx_MessageComposer_input', {
|
const className = classNames('mx_MessageComposer_input', {
|
||||||
mx_MessageComposer_input_empty: hidePlaceholder,
|
mx_MessageComposer_input_empty: hidePlaceholder,
|
||||||
|
mx_MessageComposer_input_error: this.state.someCompletions === false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const content = activeEditorState.getCurrentContent();
|
const content = activeEditorState.getCurrentContent();
|
||||||
|
|
Loading…
Reference in a new issue