Fixed channel autocomplete flickering (#5961)

Этот коммит содержится в:
Harrison Healey
2017-04-04 00:22:09 -04:00
коммит произвёл Corey Hulen
родитель 5cd0d5b87e
Коммит c4fd04efb6
7 изменённых файлов: 68 добавлений и 52 удалений

Просмотреть файл

@@ -6,7 +6,6 @@ import Provider from './provider.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
import SuggestionStore from 'stores/suggestion_store.jsx';
import {autocompleteUsersInChannel} from 'actions/user_actions.jsx';
@@ -112,7 +111,10 @@ export default class AtMentionProvider extends Provider {
handlePretextChanged(suggestionId, pretext) {
const captured = XRegExp.cache('(?:^|\\W)@([\\pL\\d\\-_.]*)$', 'i').exec(pretext.toLowerCase());
if (captured) {
if (!captured) {
return false;
}
const prefix = captured[1];
this.startNewRequest(prefix);
@@ -162,8 +164,7 @@ export default class AtMentionProvider extends Provider {
});
}
);
} else {
SuggestionStore.clearSuggestions(suggestionId);
}
return true;
}
}

Просмотреть файл

@@ -62,12 +62,12 @@ export default class ChannelMentionProvider extends Provider {
if (!captured) {
// Not a channel mention
return;
return false;
}
if (this.lastCompletedWord && captured[0].startsWith(this.lastCompletedWord)) {
// It appears we're still matching a channel handle that we already completed
return;
return false;
}
// Clear the last completed word since we've started to match new text
@@ -125,6 +125,8 @@ export default class ChannelMentionProvider extends Provider {
});
}
);
return true;
}
handleCompleteWord(term) {

Просмотреть файл

@@ -55,7 +55,7 @@ export default class EmoticonProvider {
if (partialName.length < MIN_EMOTICON_LENGTH) {
SuggestionStore.clearSuggestions(suggestionId);
return;
return false;
}
const matched = [];
@@ -117,6 +117,10 @@ export default class EmoticonProvider {
if (hasSuggestions) {
// force the selection to be cleared since the order of elements may have changed
SuggestionStore.clearSelection(suggestionId);
return true;
}
return false;
}
}

Просмотреть файл

@@ -85,5 +85,7 @@ export default class SearchChannelProvider extends Provider {
}
);
}
return Boolean(captured);
}
}

Просмотреть файл

@@ -86,5 +86,7 @@ export default class SearchUserProvider extends Provider {
}
);
}
return Boolean(captured);
}
}

Просмотреть файл

@@ -185,8 +185,13 @@ export default class SuggestionBox extends React.Component {
}
handlePretextChanged(pretext) {
let handled = false;
for (const provider of this.props.providers) {
provider.handlePretextChanged(this.suggestionId, pretext);
handled = provider.handlePretextChanged(this.suggestionId, pretext) || handled;
}
if (!handled) {
SuggestionStore.clearSuggestions(this.suggestionId);
}
}

Просмотреть файл

@@ -227,8 +227,8 @@ class SuggestionStore extends EventEmitter {
switch (type) {
case ActionTypes.SUGGESTION_PRETEXT_CHANGED:
// Clear the suggestions if the pretext is empty or has whitespace
if (other.pretext === '' || (/\s/g.test(other.pretext))) {
// Clear the suggestions if the pretext is empty or ends with whitespace
if (other.pretext === '') {
this.clearSuggestions(id);
}