From b7c481af573b30e3827188aad1681a0453942625 Mon Sep 17 00:00:00 2001
From: Jaied Al Sabid <87969327+jaieds@users.noreply.github.com>
Date: Tue, 31 Dec 2024 09:10:27 +0600
Subject: [PATCH 1/6] fix: Select story crashes after enabling multiple
---
src/components/select/select.stories.tsx | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/components/select/select.stories.tsx b/src/components/select/select.stories.tsx
index a3907c05..de2aba34 100644
--- a/src/components/select/select.stories.tsx
+++ b/src/components/select/select.stories.tsx
@@ -1,5 +1,5 @@
import type { Meta, StoryFn } from '@storybook/react';
-import { useEffect, useState } from 'react';
+import { startTransition, useLayoutEffect, useState } from 'react';
import Select from './select';
import Label from '../label';
@@ -43,22 +43,22 @@ const Template: Story = ( args ) => {
setSelected( value as unknown as string | [] );
};
- useEffect( () => {
+ // Reset selected value when multiple prop changes.
+ useLayoutEffect( () => {
if ( args?.multiple ) {
- setSelected( [] );
+ startTransition( () => {
+ setSelected( [] );
+ } );
return;
}
- setSelected( '' );
+ startTransition( () => {
+ setSelected( '' );
+ } );
}, [ args ] );
return (
-