From 5bea7819a7401ffd3fea6c0ec027d411aa913b13 Mon Sep 17 00:00:00 2001 From: Arun Chandran <53257113+Arun-cn@users.noreply.github.com> Date: Sat, 19 Oct 2024 18:10:14 +0530 Subject: [PATCH] fix(filter): ensure consistency in Language filter checkbox selection (#1557) - Fixes issue where selecting a language did not check the corresponding checkbox. - Prevents duplicate selections of the same language. - Ensures deselecting a language updates the checkbox and options properly. Closes #1519 Co-authored-by: Priyankar Pal <88102392+priyankarpal@users.noreply.github.com> --- src/common/search/FilterPlays.jsx | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/common/search/FilterPlays.jsx b/src/common/search/FilterPlays.jsx index eff222687b..61710da8fd 100644 --- a/src/common/search/FilterPlays.jsx +++ b/src/common/search/FilterPlays.jsx @@ -23,19 +23,22 @@ const FilterPlays = ({ onChange, query }) => { useEffect(() => { if (!loading && !error) { - data.languages = [ - { - name: 'JavaScript', - value: 'js', - icon: 'https://res.cloudinary.com/dgtdljyul/image/upload/v1675411496/js_jjnhvy.png' - }, - { - name: 'TypeScript', - value: 'ts', - icon: 'https://res.cloudinary.com/dgtdljyul/image/upload/v1675409456/ts_yrzjge.png' - } - ]; - setLoadedData(data); + const updatedData = { + ...data, + languages: [ + { + name: 'JavaScript', + value: 'js', + icon: 'https://res.cloudinary.com/dgtdljyul/image/upload/v1675411496/js_jjnhvy.png' + }, + { + name: 'TypeScript', + value: 'ts', + icon: 'https://res.cloudinary.com/dgtdljyul/image/upload/v1675409456/ts_yrzjge.png' + } + ] + }; + setLoadedData(updatedData); } }, [query, loading, showModal]);