PLT-2643 Fixed asynchronous autocomplete incorrectly replacing text (#3167)
* Allowed different suggestions to match different text. Added a Suggestion base component. Improved text replacement used when filling in suggestions * Fixed formatting
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
6e6257fcca
Коммит
12f6593727
@@ -1,11 +1,13 @@
|
||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
class CommandSuggestion extends React.Component {
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
|
||||
import Suggestion from './suggestion.jsx';
|
||||
|
||||
class CommandSuggestion extends Suggestion {
|
||||
render() {
|
||||
const {item, isSelection, onClick} = this.props;
|
||||
|
||||
@@ -30,16 +32,10 @@ class CommandSuggestion extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
CommandSuggestion.propTypes = {
|
||||
item: React.PropTypes.object.isRequired,
|
||||
isSelection: React.PropTypes.bool,
|
||||
onClick: React.PropTypes.func
|
||||
};
|
||||
|
||||
export default class CommandProvider {
|
||||
handlePretextChanged(suggestionId, pretext) {
|
||||
if (pretext.startsWith('/')) {
|
||||
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion);
|
||||
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion, pretext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user