Skip to content

Commit

Permalink
ensure that click on typeahead options doesn’t change the url hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Breed committed Mar 11, 2015
1 parent b834aed commit c86c9e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/typeahead/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ var TypeaheadOption = React.createClass({
render: function() {
var classes = {
hover: this.props.hover
}
};
classes[this.props.customClasses.listItem] = !!this.props.customClasses.listItem;
var classList = React.addons.classSet(classes);

return (
<li className={classList} onClick={this._onClick}>
<a href="#" className={this._getClasses()} ref="anchor">
<a href="javascript: void 0;" className={this._getClasses()} ref="anchor">
{ this.props.children }
</a>
</li>
Expand Down
8 changes: 8 additions & 0 deletions test/typeahead-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ describe('Typeahead Component', function() {
}, this);
});

it('does not change the url hash when clicking on options', function() {
var results = simulateTextInput(this.component, 'o');
var firstResult = results[0];
var anchor = TestUtils.findRenderedDOMComponentWithTag(firstResult, 'a');
var href = anchor.getDOMNode().getAttribute('href');
assert.notEqual(href, '#');
});

describe('keyboard controls', function() {
it('down arrow + return selects an option', function() {
var results = simulateTextInput(this.component, 'o');
Expand Down

0 comments on commit c86c9e6

Please sign in to comment.