Skip to content

Commit

Permalink
feat(FOROME-1061): add common variable
Browse files Browse the repository at this point in the history
  • Loading branch information
QSdmitrioul committed May 23, 2022
1 parent 0294569 commit 3b1ad49
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/enum-condition/enum-condition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ interface IEnumCondition {
) => void
}

const initialCount = 12

export const EnumCondition = observer(
({
isRefiner,
Expand All @@ -61,7 +63,7 @@ export const EnumCondition = observer(
)
const [searchValue, setSearchValue] = useState('')
const [currentPage, setCurrentPage] = useState(0)
const [variantsPerPage, setVariantsPerPage] = useState<number>(12)
const [variantsPerPage, setVariantsPerPage] = useState<number>(initialCount)

const isBlockAddBtn = !selectedVariants.length || !isFilterTouched

Expand All @@ -80,10 +82,8 @@ export const EnumCondition = observer(
const { height } = entries[0].contentRect
const heightOfElement = 32

if (
height / heightOfElement !== variantsPerPage &&
height / heightOfElement > 12
) {
const newCount = height / heightOfElement
if (newCount !== variantsPerPage && newCount > initialCount) {
setVariantsPerPage(height / 32)
}
})
Expand Down Expand Up @@ -167,7 +167,7 @@ export const EnumCondition = observer(
</>
)}

{enumVariants.length > 12 && (
{enumVariants.length > initialCount && (
<QueryBuilderSearch
value={searchValue}
onChange={handleSearchChange}
Expand Down

0 comments on commit 3b1ad49

Please sign in to comment.