99} from "@easyblocks/core/_internals" ;
1010import { ButtonGhost , Icons , Typography } from "@easyblocks/design-system" ;
1111import { toArray } from "@easyblocks/utils" ;
12- import React , { useContext } from "react" ;
12+ import React , { useContext , useRef } from "react" ;
1313import type { FieldRenderProps } from "react-final-form" ;
1414import { css } from "styled-components" ;
1515import { useEditorContext } from "../../../EditorContext" ;
@@ -25,6 +25,8 @@ function IdentityField({ input, field }: IdentityFieldProps) {
2525 const editorContext = useEditorContext ( ) ;
2626 const panelContext = useContext ( PanelContext ) ;
2727
28+ const changeComponentButton = useRef < HTMLButtonElement > ( null ) ;
29+
2830 const isMixed = isMixedFieldValue ( input . value ) ;
2931 const config = isMixed ? null : input . value ;
3032
@@ -71,8 +73,10 @@ function IdentityField({ input, field }: IdentityFieldProps) {
7173
7274 const componentPickerPath = parent . path + "." + parent . fieldName ;
7375
76+ const domRect = changeComponentButton ?. current ?. getBoundingClientRect ( ) ;
77+
7478 editorContext . actions
75- . openComponentPicker ( { path : componentPickerPath } )
79+ . openComponentPicker ( { path : componentPickerPath , domRect } )
7680 . then ( ( selectedConfig ) => {
7781 if ( ! selectedConfig ) {
7882 return ;
@@ -142,7 +146,10 @@ function IdentityField({ input, field }: IdentityFieldProps) {
142146 < div style = { { padding : "7px 6px" } } > { titleContent } </ div >
143147 ) }
144148 { ! isNonChangable && (
145- < ButtonGhost onClick = { handleChangeComponentType } >
149+ < ButtonGhost
150+ ref = { changeComponentButton }
151+ onClick = { handleChangeComponentType }
152+ >
146153 { titleContent }
147154 </ ButtonGhost >
148155 ) }
0 commit comments