Skip to content

Commit

Permalink
chore(lint): fix prettier and eslint check
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex S committed Nov 9, 2017
1 parent a3a5947 commit b95c3b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/css/theme/_search-box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
white-space: nowrap;
font-size: 14px;


&--input {
appearance: none;
font: inherit;
Expand Down
35 changes: 21 additions & 14 deletions src/widgets/search-box/search-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ const renderer = ({
wrapInput,
reset,
magnifier,
}) => ({ refine, clear, query, onHistoryChange, isSearchStalled}, isFirstRendering) => {
}) => (
{ refine, clear, query, onHistoryChange, isSearchStalled },
isFirstRendering
) => {
if (isFirstRendering) {
const INPUT_EVENT = window.addEventListener ? 'input' : 'propertychange';
const input = createInput(containerNode);
Expand Down Expand Up @@ -106,19 +109,7 @@ const renderer = ({
}
}
} else {
const input = getInput(containerNode);
const isFocused = document.activeElement === input;
if (!isFocused && query !== input.value) {
input.value = query;
}

if (magnifier) {
if (isSearchStalled) {
containerNode.firstChild.classList.add('stalled-search');
} else {
containerNode.firstChild.classList.remove('stalled-search');
}
}
renderAfterInit({ containerNode, query, magnifier, isSearchStalled });
}

if (reset) {
Expand All @@ -135,6 +126,22 @@ const renderer = ({
}
};

function renderAfterInit({ containerNode, query, magnifier, isSearchStalled }) {
const input = getInput(containerNode);
const isFocused = document.activeElement === input;
if (!isFocused && query !== input.value) {
input.value = query;
}

if (magnifier) {
if (isSearchStalled) {
containerNode.firstChild.classList.add('stalled-search');
} else {
containerNode.firstChild.classList.remove('stalled-search');
}
}
}

const usage = `Usage:
searchBox({
container,
Expand Down

0 comments on commit b95c3b0

Please sign in to comment.