From f017634ba670e9992208b155fbd52821b07e6eb8 Mon Sep 17 00:00:00 2001 From: lavanya-bmw <106523828+lavanya-bmw@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:07:51 +0530 Subject: [PATCH] fix(select list): update select list default value (#87) --- CHANGELOG.md | 4 ++++ DEPENDENCIES | 2 +- package.json | 2 +- src/components/basic/SelectList/SelectList.stories.tsx | 1 + src/components/basic/SelectList/index.tsx | 2 +- src/components/content/Cards/Card.tsx | 3 +-- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc742563..f8a9d47f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.1.22 + +- Select list default value functionality fix + ## 2.1.21 - Add option to give an image element to Cards diff --git a/DEPENDENCIES b/DEPENDENCIES index 9003a652..0bfd9e3a 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1266,7 +1266,7 @@ npm/npmjs/@rollup/pluginutils/5.0.2, MIT, approved, clearlydefined npm/npmjs/@sinclair/typebox/0.24.51, MIT, approved, #3330 npm/npmjs/@sinclair/typebox/0.27.8, MIT, approved, clearlydefined npm/npmjs/@sinonjs/commons/1.8.6, BSD-3-Clause, approved, #4340 -npm/npmjs/@sinonjs/commons/3.0.0, BSD-3-Clause, approved, clearlydefined +npm/npmjs/@sinonjs/commons/3.0.0, BSD-3-Clause, approved, #12905 npm/npmjs/@sinonjs/fake-timers/10.3.0, BSD-3-Clause, approved, #9214 npm/npmjs/@sinonjs/fake-timers/9.1.2, BSD-3-Clause, approved, #1957 npm/npmjs/@storybook/addon-actions/7.0.26, MIT, approved, #8972 diff --git a/package.json b/package.json index 2ab0d726..dfe2a6d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@catena-x/portal-shared-components", - "version": "2.1.21", + "version": "2.1.22", "description": "Catena-X Portal Shared Components", "author": "Catena-X Contributors", "license": "Apache-2.0", diff --git a/src/components/basic/SelectList/SelectList.stories.tsx b/src/components/basic/SelectList/SelectList.stories.tsx index 345bb97a..4e7a58e2 100644 --- a/src/components/basic/SelectList/SelectList.stories.tsx +++ b/src/components/basic/SelectList/SelectList.stories.tsx @@ -79,6 +79,7 @@ SelectList.args = { clearText: 'clear', noOptionsText: 'No Options', popperHeight: 0, // 0 = auto size + defaultValue: countries[0], onChangeItem: (item: any) => console.log('selected:', item), keyTitle: 'title', } diff --git a/src/components/basic/SelectList/index.tsx b/src/components/basic/SelectList/index.tsx index 13c82943..443a5bd2 100644 --- a/src/components/basic/SelectList/index.tsx +++ b/src/components/basic/SelectList/index.tsx @@ -65,7 +65,7 @@ export const SelectList = ({ const selectHeight = popperHeight ? `${popperHeight}px` : 'auto' // Add an ESLint exception until there is a solution // eslint-disable-next-line - const [selected, setSelected] = useState({}) + const [selected, setSelected] = useState(defaultValue || {}) return ( { sortOption !== '' && - submenuClick !== undefined && - submenuClick(sortOption, id) + submenuClick?.(sortOption, id) }, [sortOption, submenuClick, id]) useEffect(() => {