From fb9a618b3632357f6158975dab2656f3662724d4 Mon Sep 17 00:00:00 2001 From: Mohsin Hayat Date: Wed, 29 Jan 2025 19:04:17 +0500 Subject: [PATCH] ET-848: Add local storage persistence for select and ICD options (#183) * feat(select, icd-classification): Add local storage persistence for select and ICD options - Enhance Select component to handle search value when options are selected - Implement local storage caching for ICD classification options and search value - Improve user experience by preserving search context across page reloads * feat(icd-classification): Add question-specific local storage for ICD options - Modify useICDClassificationList hook to support question-specific local storage - Update Question component to pass question ID to the hook - Ensure ICD classification options and search values are stored uniquely per question * fix(select): Prevent unnecessary dropdown opening after exact label search - Add condition to close dropdown when search value matches selected option's label - Improve search behavior for select component when allowSearchAfterSelect is true --- src/atoms/select/Select.tsx | 27 +++++++++++++++++-- .../useIcdClassficationList.ts | 12 +++++++-- src/molecules/question/Question.tsx | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/atoms/select/Select.tsx b/src/atoms/select/Select.tsx index a56f5a8..77c19c4 100644 --- a/src/atoms/select/Select.tsx +++ b/src/atoms/select/Select.tsx @@ -11,7 +11,7 @@ import React, { import classes from './select.module.scss' import { QuestionLabel } from '../questionLabel' import { type Option } from './types' -import { isNil, noop } from 'lodash' +import { isEmpty, isNil, noop } from 'lodash' import { FixedSizeList as List } from 'react-window' export interface SelectProps @@ -147,9 +147,10 @@ export const Select = ({ return value as Array