Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
fix(content): Fix suggestion index
Browse files Browse the repository at this point in the history
  • Loading branch information
sarracini committed Jun 9, 2016
1 parent 667f448 commit df08594
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion content-src/components/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const Search = React.createClass({
const active = (this.state.activeSuggestionIndex === suggestionsIdIndex);
const activeEngine = this.getActiveEngine();
return (<li key={suggestion} role="presentation">
<a ref={"search-suggestions-" + suggestionsIdIndex++ } id={"search-suggestions-" + suggestionsIdIndex++ }
<a ref={suggestion} id={"search-suggestions-" + suggestionsIdIndex++ }
className={active ? "active" : ""} role="option"
aria-selected={active}
onClick={() => this.performSearch({engineName: activeEngine, searchString: suggestion})}>{suggestion}</a>
Expand Down
8 changes: 4 additions & 4 deletions content-test/components/Search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe("Search", () => {
assert.equal(instance.state.activeEngineIndex, 0);
assert.equal(instance.state.activeIndex, 2);
// Moving up one more will reset the active engine, as there are no more engines
// to visit, and will reset the the active index
// to visit, and will decrease the active index
TestUtils.Simulate.keyDown(instance.refs.searchInput, {key: "ArrowUp"});
assert.equal(instance.state.activeEngineIndex, -1);
assert.equal(instance.state.activeIndex, 1);
Expand All @@ -256,7 +256,7 @@ describe("Search", () => {
setup(props);
// make sure the drop down is 'visible', set the active suggestion to -1, as we
// are navigating through engines list and the active engine to the first available
// engine. Press tab to move forwards to next available engine
// engine. Press 'Tab' to move forwards to next available engine
instance.setState({focus: true, activeSuggestionIndex: -1, activeIndex: 2, activeEngineIndex: 0});
TestUtils.Simulate.keyDown(instance.refs.searchInput, {key: "Tab"});
assert.equal(instance.state.activeEngineIndex, 1);
Expand All @@ -272,7 +272,7 @@ describe("Search", () => {
setup(props);
// make sure the drop down is 'visible', set the active suggestion to -1, as we
// are navigating through engines list and the active engine to the second available
// engine. Press Tab + Shift to move backwards to next available engine
// engine. Press 'Shift + Tab' to move backwards to next available engine
instance.setState({focus: true, activeSuggestionIndex: -1, activeIndex: 3, activeEngineIndex: 1});
TestUtils.Simulate.keyDown(instance.refs.searchInput, {key: "Tab", shiftKey: true});
assert.equal(instance.state.activeEngineIndex, 0);
Expand Down Expand Up @@ -343,7 +343,7 @@ describe("Search", () => {
// available suggestion, and the active engine to -1 so it uses the default
// engine. Click on the suggestion.
instance.setState({focus: true, activeSuggestionIndex: 0, activeIndex: 0, activeEngineIndex: -1});
TestUtils.Simulate.click(instance.refs["search-suggestions-0"]);
TestUtils.Simulate.click(instance.refs.hello);
});

it("should perform a search if you click on a non-default engine with a search string provided", done => {
Expand Down

0 comments on commit df08594

Please sign in to comment.