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

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

* Check if suggestion is for a top-level command
This commit is contained in:
Michael Kochell 2020-10-05 15:08:57 -04:00 committed by GitHub
parent 40b650bcd9
commit a6779f4293
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}