Skip to content

Commit

Permalink
Merge pull request #1937 from rtibbles/simplified_undefineds
Browse files Browse the repository at this point in the history
Catch undefined cases in simplified login
  • Loading branch information
indirectlylit committed Aug 2, 2017
2 parents d4c0ea7 + 9c35194 commit f48b438
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions kolibri/plugins/user/assets/src/views/sign-in-page/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,21 @@
});
},
setSuggestionTerm(newVal, oldVal) {
if (newVal.length < 3) {
// Don't search for suggestions if less than 3 characters entered
this.suggestionTerm = '';
this.usernameSuggestions = [];
} else if ((!newVal.startsWith(this.suggestionTerm) && this.suggestionTerm.length) ||
!this.suggestionTerm.length) {
// We have already set a suggestion search term
// The currently set suggestion term does not match the current username
// Or we do not currently have a suggestion term set
// Set it to the new term and fetch new suggestions
this.suggestionTerm = newVal;
this.setSuggestions();
if (newVal !== null || typeof newVal !== 'undefined') {
// Only check if defined or not null
if (newVal.length < 3) {
// Don't search for suggestions if less than 3 characters entered
this.suggestionTerm = '';
this.usernameSuggestions = [];
} else if ((!newVal.startsWith(this.suggestionTerm) && this.suggestionTerm.length) ||
!this.suggestionTerm.length) {
// We have already set a suggestion search term
// The currently set suggestion term does not match the current username
// Or we do not currently have a suggestion term set
// Set it to the new term and fetch new suggestions
this.suggestionTerm = newVal;
this.setSuggestions();
}
}
},
setSuggestions() {
Expand All @@ -186,8 +189,11 @@
.catch(err => { this.usernameSuggestions = []; });
},
fillUsername(username) {
this.username = username;
this.showDropdown = false;
// Only do this if we have been passed a non-null value
if (username !== null || typeof username !== 'undefined') {
this.username = username;
this.showDropdown = false;
}
},
},
vuex: {
Expand Down

0 comments on commit f48b438

Please sign in to comment.