From 8c8aef99395542b13355625c6fac522ee42826df Mon Sep 17 00:00:00 2001 From: dev-opsss Date: Wed, 9 Apr 2025 10:33:34 -0500 Subject: [PATCH] component rendered timeout --- src/components/Queue/QueueCommands.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Queue/QueueCommands.tsx b/src/components/Queue/QueueCommands.tsx index c7c6c73..218f83b 100644 --- a/src/components/Queue/QueueCommands.tsx +++ b/src/components/Queue/QueueCommands.tsx @@ -400,7 +400,8 @@ const QueueCommands: React.FC = ({ /> ); - // Use setTimeout to ensure the component has rendered + // Use a small delay to ensure the component has rendered + // 50ms is generally enough for React to complete a render cycle setTimeout(() => { // Extract options from the rendered select element const selectElement = hiddenRenderContainer.querySelector('select'); @@ -420,7 +421,7 @@ const QueueCommands: React.FC = ({ // Clean up root.unmount(); document.body.removeChild(hiddenRenderContainer); - }, 0); + }, 50); // Increased timeout to ensure render completes }} tabIndex={0} onKeyDown={(e) => { @@ -442,7 +443,8 @@ const QueueCommands: React.FC = ({ /> ); - // Use setTimeout to ensure the component has rendered + // Use a small delay to ensure the component has rendered + // 50ms is generally enough for React to complete a render cycle setTimeout(() => { // Extract options from the rendered select element const selectElement = hiddenRenderContainer.querySelector('select'); @@ -471,7 +473,7 @@ const QueueCommands: React.FC = ({ // Clean up root.unmount(); document.body.removeChild(hiddenRenderContainer); - }, 0); + }, 50); // Increased timeout to ensure render completes } }} >