From 45335a13502abe8b7d64fdacb7df0e7ea91da87e Mon Sep 17 00:00:00 2001 From: CodeTanish Date: Sat, 3 May 2025 17:52:52 +0530 Subject: [PATCH 1/2] search feature fix with an additional update debouncing --- src/cra-project/components/ProjectList/CardsContainer.jsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cra-project/components/ProjectList/CardsContainer.jsx b/src/cra-project/components/ProjectList/CardsContainer.jsx index fc4da2f..3266b31 100644 --- a/src/cra-project/components/ProjectList/CardsContainer.jsx +++ b/src/cra-project/components/ProjectList/CardsContainer.jsx @@ -85,12 +85,8 @@ export default class CardsContainer extends React.Component { // Search input handler handleChange(event) { - this.inputValue = event.currentTarget.value; - - this.inputValue = this.inputValue.trim(); - this.inputValue = this.inputValue.toLowerCase(); - - this.handleFilterListUpdate(this.value); + this.inputValue = event.target.value.trim().toLowerCase(); + this.handleFilterListUpdate(this.state.value); } sortArrayRandom(array) { From c8a4bba6d684bd0595b06fd62314c8bd22cb775c Mon Sep 17 00:00:00 2001 From: CodeTanish Date: Sat, 3 May 2025 17:59:52 +0530 Subject: [PATCH 2/2] search feature fix with an additional update debouncing --- .../components/ProjectList/CardsContainer.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cra-project/components/ProjectList/CardsContainer.jsx b/src/cra-project/components/ProjectList/CardsContainer.jsx index 3266b31..0bf53d1 100644 --- a/src/cra-project/components/ProjectList/CardsContainer.jsx +++ b/src/cra-project/components/ProjectList/CardsContainer.jsx @@ -89,6 +89,20 @@ export default class CardsContainer extends React.Component { this.handleFilterListUpdate(this.state.value); } + //debounce functionality in searh + // handleChange(event) { + // const newInput = event.target.value.trim().toLowerCase(); + // this.inputValue = newInput; + + // // 🔁 Clear the previous debounce timer if still waiting + // if (this.debounceTimeout) clearTimeout(this.debounceTimeout); + + // // ⏳ Set a new debounce timer (300ms) + // this.debounceTimeout = setTimeout(() => { + // this.handleFilterListUpdate(this.state.value); // 🔍 Run filtering logic + // }, 300); // ⏱️ Delay (in milliseconds) + // } + sortArrayRandom(array) { if (Array.isArray(array)) { return array.sort(() => 0.5 - Math.random());