From e2039415ff04f839840f7021e695f036a59aded1 Mon Sep 17 00:00:00 2001 From: boyvanov Date: Mon, 24 Oct 2022 10:46:33 +0300 Subject: [PATCH] fix(ott-2710): mobile test fixes --- .../HeaderFilters/store/hooks/index.tsx | 12 +++++------ .../store/hooks/useMatchFilters.tsx | 18 +++++++++++------ .../components/ClearFiltersPopup/index.tsx | 5 +++-- .../components/ClearFiltersPopup/styled.tsx | 20 +++++++++++++------ .../HomePage/components/Dropdown/styled.tsx | 2 ++ .../components/MatchesFilters/index.tsx | 16 +++++++-------- .../components/MobileMatchesFilters/index.tsx | 12 +++++------ src/features/HomePage/index.tsx | 4 ++-- 8 files changed, 53 insertions(+), 36 deletions(-) diff --git a/src/features/HeaderFilters/store/hooks/index.tsx b/src/features/HeaderFilters/store/hooks/index.tsx index 4005bf69..87ac6009 100644 --- a/src/features/HeaderFilters/store/hooks/index.tsx +++ b/src/features/HeaderFilters/store/hooks/index.tsx @@ -41,18 +41,18 @@ export const useFilters = () => { closeDropdownList, confirmClear, currentFilters, + filtersListName, filtersSize, getDropdownList, handleSetFilters, inputValue, isEmptyFilters, isFiltersShown, - isOpenList, matchesList, - openDropdownList, openPopup, queryParams, setTournamentMatches, + toggleDropdownList, } = useMatchFilters({ selectedDate, selectedTournament, @@ -111,6 +111,7 @@ export const useFilters = () => { closeDropdownList, confirmClear, currentFilters, + filtersListName, filtersSize, getDropdownList, handleClickBack, @@ -118,11 +119,9 @@ export const useFilters = () => { inputValue, isEmptyFilters, isFiltersShown, - isOpenList, isShowTournament, isTodaySelected, matchesList, - openDropdownList, openPopup, queryParams, resetFilters, @@ -139,6 +138,7 @@ export const useFilters = () => { setSelectedTournament, setSportIds, sportIds, + toggleDropdownList, updateDate, }), [ activeFilters, @@ -150,6 +150,7 @@ export const useFilters = () => { closeDropdownList, confirmClear, currentFilters, + filtersListName, filtersSize, getDropdownList, handleClickBack, @@ -157,11 +158,9 @@ export const useFilters = () => { inputValue, isEmptyFilters, isFiltersShown, - isOpenList, isShowTournament, isTodaySelected, matchesList, - openDropdownList, openPopup, queryParams, resetFilters, @@ -178,6 +177,7 @@ export const useFilters = () => { setSelectedTournament, setSportIds, sportIds, + toggleDropdownList, updateDate, ]) diff --git a/src/features/HeaderFilters/store/hooks/useMatchFilters.tsx b/src/features/HeaderFilters/store/hooks/useMatchFilters.tsx index 93e69f61..27add7eb 100644 --- a/src/features/HeaderFilters/store/hooks/useMatchFilters.tsx +++ b/src/features/HeaderFilters/store/hooks/useMatchFilters.tsx @@ -68,17 +68,23 @@ export const useMatchFilters = ({ }: TUseMatchFilters) => { const [matchesList, setMatchesList] = useState>([]) const [tournamentMatches, setTournamentMatches] = useState>([]) - const [isOpenList, setOpenList] = useState('') + const [filtersListName, setFiltersListName] = useState('') const [activeFilters, setActiveFilters] = useState(DEFAULT_FILTERS) const [inputValue, setInputValue] = useState('') const [openPopup, setOpenPopup] = useState(false) - const openDropdownList = (title: string) => () => { - setOpenList(title === isOpenList ? '' : title) + const toggleDropdownList = (title: string) => () => { + if (title === filtersListName) { + setFiltersListName('') + setInputValue('') + } else { + setFiltersListName(title) + } } const closeDropdownList = () => { - setOpenList('') + setFiltersListName('') + setInputValue('') } const clearAllFilters = () => { @@ -266,17 +272,17 @@ export const useMatchFilters = ({ closeDropdownList, confirmClear, currentFilters, + filtersListName, filtersSize, getDropdownList, handleSetFilters, inputValue, isEmptyFilters, isFiltersShown, - isOpenList, matchesList, - openDropdownList, openPopup, queryParams, setTournamentMatches, + toggleDropdownList, } } diff --git a/src/features/HomePage/components/ClearFiltersPopup/index.tsx b/src/features/HomePage/components/ClearFiltersPopup/index.tsx index 3a510448..53eaa51e 100644 --- a/src/features/HomePage/components/ClearFiltersPopup/index.tsx +++ b/src/features/HomePage/components/ClearFiltersPopup/index.tsx @@ -1,6 +1,6 @@ import { useHeaderFiltersStore } from 'features/HeaderFilters' import { T9n } from 'features/T9n' -import React from 'react' + import { ButtonsContainer, CancelButton, @@ -25,7 +25,8 @@ export const ClearFiltersPopup = () => { - + {/* */} + Do you want to clear all filter selections? diff --git a/src/features/HomePage/components/ClearFiltersPopup/styled.tsx b/src/features/HomePage/components/ClearFiltersPopup/styled.tsx index fa8971c6..caebc2a2 100644 --- a/src/features/HomePage/components/ClearFiltersPopup/styled.tsx +++ b/src/features/HomePage/components/ClearFiltersPopup/styled.tsx @@ -1,23 +1,31 @@ import styled, { css } from 'styled-components/macro' import { ModalWindow } from 'features/Modal/styled' +import { OutsideClickWrapper } from 'features/OutsideClick' import { Modal as BaseModal, } from 'features/AuthServiceApp/components/RegisterPopup/styled' import { isMobileDevice } from 'config/userAgent' export const Modal = styled(BaseModal)` + ${OutsideClickWrapper} { + ${isMobileDevice + ? css`height: 100%;` + : ''} + } + ${ModalWindow} { ${isMobileDevice ? css` - min-height: 201px; - max-width: 351px; - padding: 26px 19px 33px 19px; + min-height: 201px; + max-width: 351px; + padding: 26px 15px 33px 15px; + top: 19vh; ` : css` - min-height: 220px; - max-width: 611px; - padding: 37px 0 39px 0; + min-height: 220px; + max-width: 611px; + padding: 37px 0 39px 0; `} } ` diff --git a/src/features/HomePage/components/Dropdown/styled.tsx b/src/features/HomePage/components/Dropdown/styled.tsx index 95dcd375..9817904a 100644 --- a/src/features/HomePage/components/Dropdown/styled.tsx +++ b/src/features/HomePage/components/Dropdown/styled.tsx @@ -1,4 +1,5 @@ import styled, { css } from 'styled-components/macro' + import { customScrollbar } from 'features/Common' import { Checkbox as BaseCheckbox } from 'features/Common/Checkbox' import { Label } from 'features/Common/Checkbox/styled' @@ -17,6 +18,7 @@ export const DropDownContainer = styled.div` border-radius: 3.5px; z-index: 10;`} ` + export const FiltersList = styled.ul` overflow-y: auto; display: flex; diff --git a/src/features/HomePage/components/MatchesFilters/index.tsx b/src/features/HomePage/components/MatchesFilters/index.tsx index 5bdda89f..c25991bb 100644 --- a/src/features/HomePage/components/MatchesFilters/index.tsx +++ b/src/features/HomePage/components/MatchesFilters/index.tsx @@ -54,13 +54,13 @@ export const MatchesFilters = ({ isMobile }: TFiltersProps) => { changeInput, clearFilters, currentFilters, + filtersListName, filtersSize, getDropdownList, handleSetFilters, inputValue, - isOpenList, matchesList, - openDropdownList, + toggleDropdownList, } = useHeaderFiltersStore() return ( @@ -79,9 +79,9 @@ export const MatchesFilters = ({ isMobile }: TFiltersProps) => { return ( {/* */} {filterTitle} @@ -111,14 +111,14 @@ export const MatchesFilters = ({ isMobile }: TFiltersProps) => { )} - {isOpenList === filterTitle && !isNil(matchesList) && !isMobileDevice && ( + {filtersListName === filterTitle && !isNil(matchesList) && !isMobileDevice && ( )} diff --git a/src/features/HomePage/components/MobileMatchesFilters/index.tsx b/src/features/HomePage/components/MobileMatchesFilters/index.tsx index 7ceb3083..b21808f6 100644 --- a/src/features/HomePage/components/MobileMatchesFilters/index.tsx +++ b/src/features/HomePage/components/MobileMatchesFilters/index.tsx @@ -26,11 +26,11 @@ export const MobileMatchesFilters = () => { clickClearAll, closeDropdownList, currentFilters, + filtersListName, filtersSize, handleSetFilters, inputValue, isEmptyFilters, - isOpenList, matchesList, } = useHeaderFiltersStore() @@ -54,7 +54,7 @@ export const MobileMatchesFilters = () => { {filtersSize !== 0 && {` ${filtersSize}`}} - {isEmpty(isOpenList) + {!filtersListName ? ( <> @@ -70,13 +70,13 @@ export const MobileMatchesFilters = () => { <> {!isNil(matchesList) && ( )} diff --git a/src/features/HomePage/index.tsx b/src/features/HomePage/index.tsx index ef514ee0..178a1346 100644 --- a/src/features/HomePage/index.tsx +++ b/src/features/HomePage/index.tsx @@ -31,7 +31,7 @@ const Home = () => { isShowConfirmPopup, setIsOpenDownload, } = useHomePage() - const { isOpenList } = useHeaderFiltersStore() + const { filtersListName } = useHeaderFiltersStore() return ( @@ -41,7 +41,7 @@ const Home = () => { setIsOpenDownload={setIsOpenDownload} /> ) : ( -
+
)}