@@ -205,6 +205,9 @@ const RegionSelectExample = () => {
205205 } ) ;
206206
207207 await step ( 'Test validation errors on invalid submission' , async ( ) => {
208+ // Wait for component to be fully loaded
209+ await canvas . findByLabelText ( 'US State' ) ;
210+
208211 // Submit form without selecting any options
209212 const submitButton = canvas . getByRole ( 'button' , { name : 'Submit' } ) ;
210213 await userEvent . click ( submitButton ) ;
@@ -288,6 +291,9 @@ export const USStateSelection: Story = {
288291 const canvas = within ( canvasElement ) ;
289292
290293 await step ( 'Select a US state' , async ( ) => {
294+ // Wait for component to be fully loaded
295+ await canvas . findByLabelText ( 'US State' ) ;
296+
291297 // Find and click the US state dropdown
292298 const stateSelect = canvas . getByLabelText ( 'US State' ) ;
293299 await userEvent . click ( stateSelect ) ;
@@ -327,6 +333,9 @@ export const CanadaProvinceSelection: Story = {
327333 const canvas = within ( canvasElement ) ;
328334
329335 await step ( 'Select a Canadian province' , async ( ) => {
336+ // Wait for component to be fully loaded
337+ await canvas . findByLabelText ( 'Canadian Province' ) ;
338+
330339 // Find and click the Canada province dropdown
331340 const provinceSelect = canvas . getByLabelText ( 'Canadian Province' ) ;
332341 await userEvent . click ( provinceSelect ) ;
@@ -366,6 +375,9 @@ export const FormSubmission: Story = {
366375 const canvas = within ( canvasElement ) ;
367376
368377 await step ( 'Select all regions' , async ( ) => {
378+ // Wait for component to be fully loaded
379+ await canvas . findByLabelText ( 'US State' ) ;
380+
369381 // Select a state
370382 const stateSelect = canvas . getByLabelText ( 'US State' ) ;
371383 await userEvent . click ( stateSelect ) ;
@@ -470,6 +482,9 @@ export const SearchDisabled: Story = {
470482 play : async ( { canvasElement, step } ) => {
471483 const canvas = within ( canvasElement ) ;
472484 await step ( 'Open select and ensure no search input' , async ( ) => {
485+ // Wait for component to be fully loaded
486+ await canvas . findByLabelText ( 'Custom Region' ) ;
487+
473488 const regionSelect = canvas . getByLabelText ( 'Custom Region' ) ;
474489 await userEvent . click ( regionSelect ) ;
475490
@@ -528,6 +543,9 @@ export const CustomSearchPlaceholder: Story = {
528543 play : async ( { canvasElement, step } ) => {
529544 const canvas = within ( canvasElement ) ;
530545 await step ( 'Open select and see custom placeholder' , async ( ) => {
546+ // Wait for component to be fully loaded
547+ await canvas . findByLabelText ( 'Custom Region' ) ;
548+
531549 const regionSelect = canvas . getByLabelText ( 'Custom Region' ) ;
532550 await userEvent . click ( regionSelect ) ;
533551
@@ -592,8 +610,13 @@ export const CreatableOption: Story = {
592610 const canvas = within ( canvasElement ) ;
593611
594612 await step ( 'Create new option when no exact match' , async ( ) => {
595- // Wait for the component to render before interacting
596- const regionSelect = await canvas . findByLabelText ( 'Custom Region' ) ;
613+ // Wait for the component to fully load - check for loading screen absence
614+ await canvas . findByLabelText ( 'Custom Region' ) ;
615+
616+ // Additional wait to ensure the component is fully interactive
617+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
618+
619+ const regionSelect = canvas . getByLabelText ( 'Custom Region' ) ;
597620 await userEvent . click ( regionSelect ) ;
598621
599622 try {
@@ -642,8 +665,13 @@ export const CreatableOption: Story = {
642665 } ) ;
643666
644667 await step ( 'No creatable when exact match exists' , async ( ) => {
645- // Wait for the component to render before interacting
646- const regionSelect = await canvas . findByLabelText ( 'Custom Region' ) ;
668+ // Wait for the component to fully load - check for loading screen absence
669+ await canvas . findByLabelText ( 'Custom Region' ) ;
670+
671+ // Additional wait to ensure the component is fully interactive
672+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
673+
674+ const regionSelect = canvas . getByLabelText ( 'Custom Region' ) ;
647675 await userEvent . click ( regionSelect ) ;
648676
649677 try {
0 commit comments