mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-14 02:38:40 +03:00
fix tab focus issue in MessageComposerInput
onTab was incorrectly implemented causing forceComplete instead of focusing the editor
This commit is contained in:
parent
aaac06c6d3
commit
46d30c378d
2 changed files with 19 additions and 8 deletions
|
@ -149,6 +149,7 @@ export default class Autocomplete extends React.Component {
|
|||
const done = Q.defer();
|
||||
this.setState({
|
||||
forceComplete: true,
|
||||
hide: false,
|
||||
}, () => {
|
||||
this.complete(this.props.query, this.props.selection).then(() => {
|
||||
done.resolve();
|
||||
|
@ -185,6 +186,11 @@ export default class Autocomplete extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
setState(state, func) {
|
||||
super.setState(state, func);
|
||||
console.log(state);
|
||||
}
|
||||
|
||||
render() {
|
||||
const EmojiText = sdk.getComponent('views.elements.EmojiText');
|
||||
|
||||
|
|
|
@ -400,7 +400,8 @@ export default class MessageComposerInput extends React.Component {
|
|||
*/
|
||||
setState(state, callback) {
|
||||
if (state.editorState != null) {
|
||||
state.editorState = RichText.attachImmutableEntitiesToEmoji(state.editorState);
|
||||
state.editorState = RichText.attachImmutableEntitiesToEmoji(
|
||||
state.editorState);
|
||||
|
||||
if (state.editorState.getCurrentContent().hasText()) {
|
||||
this.onTypingActivity();
|
||||
|
@ -413,15 +414,17 @@ export default class MessageComposerInput extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
super.setState(state, (state, props, context) => {
|
||||
super.setState(state, () => {
|
||||
if (callback != null) {
|
||||
callback(state, props, context);
|
||||
callback();
|
||||
}
|
||||
|
||||
if (this.props.onContentChanged) {
|
||||
const textContent = state.editorState.getCurrentContent().getPlainText();
|
||||
const selection = RichText.selectionStateToTextOffsets(state.editorState.getSelection(),
|
||||
state.editorState.getCurrentContent().getBlocksAsArray());
|
||||
const textContent = this.state.editorState
|
||||
.getCurrentContent().getPlainText();
|
||||
const selection = RichText.selectionStateToTextOffsets(
|
||||
this.state.editorState.getSelection(),
|
||||
this.state.editorState.getCurrentContent().getBlocksAsArray());
|
||||
|
||||
this.props.onContentChanged(textContent, selection);
|
||||
}
|
||||
|
@ -616,11 +619,13 @@ export default class MessageComposerInput extends React.Component {
|
|||
|
||||
// tab and shift-tab are mapped to down and up arrow respectively
|
||||
onTab = async (e) => {
|
||||
console.log('onTab');
|
||||
e.preventDefault(); // we *never* want tab's default to happen, but we do want up/down sometimes
|
||||
const didTab = await (e.shiftKey ? this.onUpArrow : this.onDownArrow)(e);
|
||||
if (!didTab && this.autocomplete) {
|
||||
if (this.autocomplete.state.completionList.length === 0) {
|
||||
await this.autocomplete.forceComplete();
|
||||
this.onDownArrow(e);
|
||||
} else {
|
||||
await (e.shiftKey ? this.onUpArrow : this.onDownArrow)(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue