[MM-29275]: Remove first char of slash cmd autocomplete suggestion text, only if it is a top-level command (#4868) (#4873)

* Remove first char of suggestion text, only if it is a slash

* Check if suggestion is for a top-level command

(cherry picked from commit a6779f4293)

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
This commit is contained in:
Mattermost Build 2020-10-05 15:19:42 -04:00 committed by GitHub
parent a3dae17ded
commit c9ce2338f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,11 +32,17 @@ export default class SlashSuggestionItem extends PureComponent {
hint,
theme,
suggestion,
complete,
isLandscape,
} = this.props;
const style = getStyleFromTheme(theme);
let suggestionText = suggestion;
if (suggestionText[0] === '/' && complete.split(' ').length === 1) {
suggestionText = suggestionText.substring(1);
}
return (
<TouchableWithFeedback
onPress={this.completeSuggestion}
@ -54,7 +60,7 @@ export default class SlashSuggestionItem extends PureComponent {
/>
</View>
<View style={style.suggestionContainer}>
<Text style={style.suggestionName}>{`${suggestion.substring(1)} ${hint}`}</Text>
<Text style={style.suggestionName}>{`${suggestionText} ${hint}`}</Text>
<Text
ellipsizeMode='tail'
numberOfLines={1}