Skip to content

Commit 47bc1dc

Browse files
authored
Revert "fix: modified the way we were handling fieldlocation data fetch (#462)"
This reverts commit b43682d.
1 parent 3b897a4 commit 47bc1dc

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

src/visualBuilder/components/FieldToolbar.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -392,23 +392,17 @@ function FieldToolbarComponent(
392392
};
393393
}, []);
394394

395-
396-
397395
useEffect(() => {
398-
const fetchFieldLocationData = async () => {
399-
try {
400-
const event = await visualBuilderPostMessage?.send(VisualBuilderPostMessageEvents.FIELD_LOCATION_DATA, {
401-
domEditStack: getDOMEditStack(eventDetails.editableElement)
402-
});
403-
404-
setFieldLocationData(event)
405-
} catch (error) {
406-
console.error('Error fetching field location data:', error);
396+
const event = visualBuilderPostMessage?.on(
397+
VisualBuilderPostMessageEvents.FIELD_LOCATION_DATA,
398+
(data: { data: any }) => {
399+
setFieldLocationData(data.data.fieldLocationData);
407400
}
401+
);
402+
return () => {
403+
event?.unregister();
408404
};
409-
410-
fetchFieldLocationData();
411-
}, [eventDetails.editableElement]);
405+
}, []);
412406

413407
const multipleFieldToolbarButtonClasses = classNames(
414408
"visual-builder__button visual-builder__button--secondary",

0 commit comments

Comments
 (0)