Skip to content

Commit

Permalink
refactor(WordSearchForm): regex search logic and input width
Browse files Browse the repository at this point in the history
  • Loading branch information
turdiyev committed May 3, 2019
1 parent dc80a66 commit d8d3a8a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/containers/layout/WordSearchFormComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {useState} from 'react'
import IconSearchSVG from "../../components/svg/IconSearchSVG";
import posed from "react-pose";
import styled from "styled-components";
import {debounce, includes, isEmpty, slice, startsWith} from "lodash"
import {debounce, isEmpty, slice} from "lodash"
import {LATIN_IMLO_ARRAY} from "../../constants/latinWords";

interface IProps {
Expand Down Expand Up @@ -151,9 +151,9 @@ export default function WordSearchFormComponent({}: IProps) {
resolve(LATIN_IMLO_ARRAY.filter((word: string) => {
if (searchValue) {
if (searchPlace == 'any') {
return includes(word, searchValue)
return word.search(/searchValue/ig) > -1
} else {
return startsWith(word, searchValue)
return word.search(new RegExp('^' + searchValue, 'i')) > -1
}
}
})),
Expand Down Expand Up @@ -181,6 +181,7 @@ export default function WordSearchFormComponent({}: IProps) {
<form className="word-search-box" onSubmit={searchSubmitListener}>
<input type="text"
className="word-search"
style={{minWidth:260}}
placeholder={"so'zni qidiring..."}
onKeyUp={(e: any) => debouncedKeyupListener(e.target.value, searchConfig.searchPlace)}
/>
Expand Down

0 comments on commit d8d3a8a

Please sign in to comment.