-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add search pill to filters #3763
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start on this issue @CzarekDryl 🙌
Tested your changes and it looks good on desktop
However, on mobile, I did notice the modal has a scroll even though there is enough space for it not to be shown
Screen.Recording.2024-11-26.at.17.02.49.mov
Also I left some refactoring comments which should help keep our codebase more maintainable, if you can please tackle them 🙏
const [isSearchOpened, setIsSearchOpened] = useState(false); | ||
const isMobile = useMobile(); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = | ||
usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-start', | ||
trigger: 'click', | ||
interactive: true, | ||
}); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef } = usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-start', | ||
trigger: 'click', | ||
interactive: true, | ||
visible: isSearchOpened, | ||
onVisibleChange: setIsSearchOpened, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this code
const [isSearchOpened, setIsSearchOpened] = useState(false);
const { getTooltipProps, setTooltipRef, setTriggerRef } = usePopperTooltip({
delayShow: 200,
delayHide: 200,
placement: 'bottom-start',
trigger: 'click',
interactive: true,
visible: isSearchOpened,
onVisibleChange: setIsSearchOpened,
});
is duplicated in 6 files could we please extract it into a global hook useSearchFilter
const useSearchFilter = () => {
const [isSearchOpened, setIsSearchOpened] = useState(false);
const { getTooltipProps, setTooltipRef, setTriggerRef } = usePopperTooltip({
delayShow: 200,
delayHide: 200,
placement: 'bottom-start',
trigger: 'click',
interactive: true,
visible: isSearchOpened,
onVisibleChange: setIsSearchOpened,
});
const closeSearch = () => {
setIsSearchOpened(false);
}
const openSearch = () => {
setIsSearchOpened(true);
}
const toggleSearch = () => {
setIsSearchOpened((prev) => !prev);
}
return {
getTooltipProps,
setTooltipRef,
setTriggerRef,
isSearchOpened,
closeSearch,
openSearch,
toggleSearch
}
};
and then use it here?
const {
isSearchOpened,
openSearch,
closeSearch,
toggleSearch,
getTooltipProps,
setTooltipRef,
setTriggerRef,
} = useSearchFilter();
const [isSearchOpened, setIsSearchOpened] = useState(false); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef } = usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-end', | ||
trigger: 'click', | ||
interactive: true, | ||
visible: isSearchOpened, | ||
onVisibleChange: setIsSearchOpened, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the useSearchFilter
hook here
const [isSearchOpened, setIsSearchOpened] = useState(false); | ||
const isMobile = useMobile(); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = | ||
usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-start', | ||
trigger: 'click', | ||
interactive: true, | ||
}); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef } = usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-start', | ||
trigger: 'click', | ||
interactive: true, | ||
visible: isSearchOpened, | ||
onVisibleChange: setIsSearchOpened, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the useSearchFilter
hook here
const [isSearchOpened, setIsSearchOpened] = useState(false); | ||
const isMobile = useMobile(); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = | ||
usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-end', | ||
trigger: 'click', | ||
interactive: true, | ||
}); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef } = usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-end', | ||
trigger: 'click', | ||
interactive: true, | ||
visible: isSearchOpened, | ||
onVisibleChange: setIsSearchOpened, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the useSearchFilter
hook here
const [isSearchOpened, setIsSearchOpened] = useState(false); | ||
const { getTooltipProps, setTooltipRef, setTriggerRef } = usePopperTooltip({ | ||
delayShow: 200, | ||
delayHide: 200, | ||
placement: 'bottom-end', | ||
trigger: 'click', | ||
interactive: true, | ||
visible: isSearchOpened, | ||
onVisibleChange: setIsSearchOpened, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the useSearchFilter
hook here
|
||
return ( | ||
<> | ||
<div className="flex flex-row gap-2"> | ||
{!!searchValue && !isMobile && searchPill} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then use the new component here
{!isMobile && (
<SearchPill value={searchValue} onClick={() => onSearch('')} />
)}
@@ -93,6 +103,7 @@ function Filter<TValue extends FilterValue>({ | |||
<MagnifyingGlass size={14} /> | |||
</Button> | |||
)} | |||
{!!searchValue && isMobile && searchPill} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then use the new component here
{isMobile && (
<SearchPill value={searchValue} onClick={() => onSearch('')} />
)}
@@ -66,23 +76,27 @@ const TeamsPageFilter: FC<TeamsPageFilterProps> = ({ | |||
return ( | |||
<> | |||
<div className="flex flex-row gap-2"> | |||
{!!searchValue && !isMobile && searchPill} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then use the new component here
{!isMobile && (
<SearchPill value={searchValue} onClick={() => onSearch('')} />
)}
> | ||
<MagnifyingGlass size={14} /> | ||
</Button> | ||
{!!searchValue && searchPill} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then use the new component here
<SearchPill value={searchValue} onClick={() => onSearch('')} />
@@ -64,6 +74,7 @@ const Filter: FC<FilterProps> = ({ | |||
> | |||
<MagnifyingGlass size={14} /> | |||
</Button> | |||
{!!searchValue && searchPill} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use the new component here
<SearchPill
value={searchValue}
onClick={() => setSearchValue('')}
/>
@mmioana Thanks for comments, I think scroll in search modal should be fixed in other issue. |
Description
Testing
Resolves #3666