diff --git a/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx b/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx index 562bb8c0d9..b43d2c8117 100644 --- a/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx +++ b/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx @@ -120,10 +120,8 @@ const ComponentPicker = ({ }, [editor, checkForTriggerMatch, triggerString]) const handleClose = useCallback(() => { - ReactDOM.flushSync(() => { - const escapeEvent = new KeyboardEvent('keydown', { key: 'Escape' }) - editor.dispatchCommand(KEY_ESCAPE_COMMAND, escapeEvent) - }) + const escapeEvent = new KeyboardEvent('keydown', { key: 'Escape' }) + editor.dispatchCommand(KEY_ESCAPE_COMMAND, escapeEvent) }, [editor]) const renderMenu = useCallback>(( @@ -132,7 +130,11 @@ const ComponentPicker = ({ ) => { if (!(anchorElementRef.current && (allFlattenOptions.length || workflowVariableBlock?.show))) return null - refs.setReference(anchorElementRef.current) + + setTimeout(() => { + if (anchorElementRef.current) + refs.setReference(anchorElementRef.current) + }, 0) return ( <> @@ -149,7 +151,6 @@ const ComponentPicker = ({ visibility: isPositioned ? 'visible' : 'hidden', }} ref={refs.setFloating} - data-testid="component-picker-container" > { workflowVariableBlock?.show && ( @@ -173,7 +174,7 @@ const ComponentPicker = ({
) } -
+
{ options.map((option, index) => (