mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Remove additional search code related to the up/down navigation
Removed additional search code that was related to the up/down navigation and their related tests. https://meta.discourse.org/t/magic-search-code-for-keyboard-shortcuts/19563
This commit is contained in:
parent
c41d47b8f5
commit
44a25271f1
2 changed files with 0 additions and 69 deletions
|
@ -133,23 +133,5 @@ export default Em.Controller.extend(Discourse.Presence, {
|
|||
|
||||
cancelTypeFilter: function() {
|
||||
this.set('typeFilter', null);
|
||||
},
|
||||
|
||||
moveUp: function() {
|
||||
if (this.get('selectedIndex') === 0) return;
|
||||
this.set('selectedIndex', this.get('selectedIndex') - 1);
|
||||
},
|
||||
|
||||
moveDown: function() {
|
||||
if (this.get('resultCount') === (this.get('selectedIndex') + 1)) return;
|
||||
this.set('selectedIndex', this.get('selectedIndex') + 1);
|
||||
},
|
||||
|
||||
select: function() {
|
||||
if (this.get('loading')) return;
|
||||
var href = this.get('urls')[this.get("selectedIndex")];
|
||||
if (href) {
|
||||
Discourse.URL.routeTo(href);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -128,57 +128,6 @@ test("keyboard navigation", function() {
|
|||
});
|
||||
|
||||
equal(controller.get("selectedIndex"), 0, "initially the first item is selected");
|
||||
|
||||
controller.moveUp();
|
||||
equal(controller.get("selectedIndex"), 0, "you can't move up above the first item");
|
||||
|
||||
controller.moveDown();
|
||||
equal(controller.get("selectedIndex"), 1, "you can go down from the first item");
|
||||
|
||||
controller.moveDown();
|
||||
equal(controller.get("selectedIndex"), 2, "you can go down from the middle item");
|
||||
|
||||
controller.moveDown();
|
||||
equal(controller.get("selectedIndex"), 2, "you can't go down below the last item");
|
||||
|
||||
controller.moveUp();
|
||||
equal(controller.get("selectedIndex"), 1, "you can go up from the last item");
|
||||
|
||||
controller.moveUp();
|
||||
equal(controller.get("selectedIndex"), 0, "you can go up from the middle item");
|
||||
});
|
||||
|
||||
test("selecting a highlighted item", function() {
|
||||
sandbox.stub(Discourse.URL, "routeTo");
|
||||
|
||||
var controller = this.subject();
|
||||
Ember.run(function() {
|
||||
controller.set("term", "ab");
|
||||
|
||||
searcherStub.resolve(
|
||||
{
|
||||
type: "user",
|
||||
posts: [],
|
||||
categories: [],
|
||||
topics: [],
|
||||
users: [{username: 'bob'}],
|
||||
grouped_search_result: {},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Ember.run(function() {
|
||||
controller.set("selectedIndex", 0);
|
||||
});
|
||||
controller.select();
|
||||
ok(Discourse.URL.routeTo.calledWith("/users/bob"), "when selected item has url, a redirect is fired");
|
||||
|
||||
Discourse.URL.routeTo.reset();
|
||||
Ember.run(function() {
|
||||
controller.set("loading", true);
|
||||
});
|
||||
controller.select();
|
||||
ok(!Discourse.URL.routeTo.called, "when loading flag is set to true, there is no redirect");
|
||||
});
|
||||
|
||||
test("search query / the flow of the search", function() {
|
||||
|
|
Loading…
Reference in a new issue