From f271ca9bef83cf700e223aa1b409f4e3fc4022de Mon Sep 17 00:00:00 2001 From: sabzdotpy Date: Thu, 2 Jun 2022 09:39:42 +0530 Subject: [PATCH] added search functionality in questions page --- src/pages/linkedin-practices.tsx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/pages/linkedin-practices.tsx b/src/pages/linkedin-practices.tsx index 84b138c..0b073fe 100644 --- a/src/pages/linkedin-practices.tsx +++ b/src/pages/linkedin-practices.tsx @@ -6,7 +6,35 @@ export const LinkedInPracticesPage: React.FC = () => { const { encodedUrl } = useParams<{ encodedUrl: string }>(); const url = atob(encodedUrl || ''); + const handleFilter = (event: React.ChangeEvent) => { + let questions = document.querySelectorAll( + '[aria-label="question-container"]' + ); + + questions.forEach((item: Element, index: number) => { + (questions[index].parentNode?.parentNode as HTMLElement).style.display = + item.textContent + ?.toLowerCase() + .includes(event.target.value.toLowerCase()) + ? "block" + : "none"; + }); + }; + return ( - + +
+ +
+ +
); };