Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>react-common</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rubik:300,300i,400,400i,500,500i,700,700i,900,900i&display=swap"></head><body><div id="rsg-root"></div><div id="app"></div><script src="build/bundle.99be1485.js"></script></body></html>
<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>react-common</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rubik:300,300i,400,400i,500,500i,700,700i,900,900i&display=swap"></head><body><div id="rsg-root"></div><div id="app"></div><script src="build/bundle.4744580e.js"></script></body></html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wikia/react-common",
"version": "9.14.6",
"version": "9.14.9",
"description": "Wikia's reusable React parts",
"repository": "git@github.com:Wikia/react-common.git",
"license": "UNLICENSED",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Search extends React.Component {
this.onBlur = this.onBlur.bind(this);
this.onFocus = this.onFocus.bind(this);
this.onKeyDown = this.onKeyDown.bind(this);
this.onSearchSuggestionClick = this.onSearchSuggestionClick.bind(this);
this.requestSuggestionsFromAPI = debounce(this.requestSuggestionsFromAPI.bind(this), DEBOUNCE_DURATION);
}

Expand Down Expand Up @@ -116,7 +115,7 @@ class Search extends React.Component {
}
}

onSearchSuggestionClick(index) {
onSearchSuggestionClick(index, event) {
const { track, onSearchSuggestionChosen } = this.props;
const { suggestions, suggestionId } = this.state;

Expand All @@ -129,6 +128,10 @@ class Search extends React.Component {
category: 'navigation',
label: 'search-open-suggestion-link',
});

if (event) {
event.preventDefault();
}
}

onSearchActivation() {
Expand Down Expand Up @@ -367,7 +370,7 @@ class Search extends React.Component {
<li
key={suggestion}
className={wrapperClassName}
onClick={this.onSearchSuggestionClick}
onClick={this.onSearchSuggestionClick.bind(this, index)}
onMouseEnter={this.onSuggestionHover.bind(this, index)}
>
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ describe('onSearchSuggestionClick', () => {
track: trackMock,
}).setState(stateMock);
const instance = wrapper.instance();
const event = {
preventDefault: jest.fn(),
};

instance.onSearchClose = onSearchCloseMock;

Expand All @@ -286,6 +289,14 @@ describe('onSearchSuggestionClick', () => {
expect(onSearchSuggestionChosenMock).toBeCalledWith(suggestionsMock[1], suggestionsMock, suggestionIdMock);
expect(onSearchCloseMock).toBeCalledWith();
expect(trackMock).toBeCalledWith(expect.any(Object));
expect(event.preventDefault).not.toBeCalled();

instance.onSearchSuggestionClick(1, event);

expect(onSearchSuggestionChosenMock).toBeCalledWith(suggestionsMock[1], suggestionsMock, suggestionIdMock);
expect(onSearchCloseMock).toBeCalledWith();
expect(trackMock).toBeCalledWith(expect.any(Object));
expect(event.preventDefault).toBeCalled();
});
});

Expand Down