diff --git a/test/spec/groupCtrlSpec.js b/test/spec/groupCtrlSpec.js index fa7148527c..7e7abb598d 100644 --- a/test/spec/groupCtrlSpec.js +++ b/test/spec/groupCtrlSpec.js @@ -137,23 +137,28 @@ describe("Autocomplete controller", function() { }) describe("filterUser", function() { - it('filters with undefined query (not loaded yet) and defaults to true', function() { - expect(scope.filterUser({user: "boo"})).to.be.eq(true); + it('filters with undefined query (not loaded yet) and returns false (so it will not be rendered)', function() { + expect(scope.filterUser({user: "boo"})).to.be.eq(false); }) - it('filters with null query (no typing yet) and defaults to true', function() { + it('filters with null query (no typing yet) and returns false (so it will not be rendered)', function() { scope.query = null - expect(scope.filterUser({user: "boo"})).to.be.ok + expect(scope.filterUser({user: "boo"})).to.be.eq(false); + }) + + it('filters with empty prefix and returns true', function() { + scope.query = {text: ""} + expect(scope.filterUser({user: "prefix"})).to.be.eq(true); }) it('filters with prefix element and returns true', function() { scope.query = {text: "pre"} - expect(scope.filterUser({user: "prefix"})).to.be.ok + expect(scope.filterUser({user: "prefix"})).to.be.eq(true); }) it('filters with nonprefix element and returns false', function() { scope.query = {text: "noprefix"} - expect(scope.filterUser({user: "prefix"})).to.not.be.ok + expect(scope.filterUser({user: "prefix"})).to.be.eq(false); }) }); }); diff --git a/website/public/js/controllers/groupsCtrl.js b/website/public/js/controllers/groupsCtrl.js index a16665b602..7dfdf5a84f 100644 --- a/website/public/js/controllers/groupsCtrl.js +++ b/website/public/js/controllers/groupsCtrl.js @@ -220,11 +220,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' $scope.usernames = []; } - $scope.filterUser = function(userItem) { + $scope.filterUser = function(msg) { if ($scope.query === undefined || $scope.query === null) { - return true; + return false; } - return userItem.user.indexOf($scope.query.text) == 0; // query should be prefix of item.user + return msg.user.indexOf($scope.query.text) == 0; // query should be prefix of item.user } $scope.addNewUser = function(user) { diff --git a/website/views/options/social/chat-box.jade b/website/views/options/social/chat-box.jade index edc78f8eed..047f6e4eea 100644 --- a/website/views/options/social/chat-box.jade +++ b/website/views/options/social/chat-box.jade @@ -15,8 +15,8 @@ form.chat-form(ng-if='user.flags.communityGuidelinesAccepted' ng-submit='postCha textarea.form-control(rows=4, ui-keydown='{"meta-enter":"postChat(group,message.content)"}', ui-keypress='{13:"postChat(group,message.content)"}', ng-model='message.content', updateinterval='250', flag='@', at-user, auto-complete placeholder="{{group._id == 'habitrpg' ? env.t('tavernCommunityGuidelinesPlaceholder') : ''}}") span.user-list(ng-show='!isAtListHidden') ul.list-at-user - li(ng-repeat='user in response | filter:filterUser | limitTo: 5', ng-click='autoComplete(user)') - span.username.label.label-default(ng-class=':: userLevelStyle(user)') {{::user.user}} + li(ng-repeat='msg in response | filter:filterUser | limitTo: 5', ng-click='autoComplete(msg)') + span.username.label.label-default(ng-class=':: userLevelStyle(msg)') {{::msg.user}} .chat-controls .chat-formatting include ../../shared/formatting-help