Skip to content

Commit

Permalink
Merge pull request #313 from contentstack/VE-4033
Browse files Browse the repository at this point in the history
fix: remove useSignal
  • Loading branch information
hiteshshetty-dev authored Dec 20, 2024
2 parents fae6b68 + e3baeec commit 4588512
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/visualBuilder/components/FieldToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useSignal } from "@preact/signals";
import { CslpData } from "../../cslp/types/cslp.types";
import getChildrenDirection from "../utils/getChildrenDirection";
import {
Expand Down Expand Up @@ -113,10 +112,11 @@ function FieldToolbarComponent(
): JSX.Element | null {
const { eventDetails } = props;
const { fieldMetadata, editableElement: targetElement } = eventDetails;
const direction = useSignal("");

const parentPath =
fieldMetadata?.multipleFieldMetadata?.parentDetails?.parentCslpValue ||
"";
const direction = getChildrenDirection(targetElement, parentPath);
const isVariant = !!fieldMetadata?.variant;
const [fieldSchema, setFieldSchema] = useState<ISchemaFieldMap | null>(
null
Expand Down Expand Up @@ -176,8 +176,6 @@ function FieldToolbarComponent(
}
}

direction.value = getChildrenDirection(targetElement, parentPath);

const invertTooltipPosition =
targetElement.getBoundingClientRect().top <= TOOLTIP_TOP_EDGE_BUFFER;

Expand Down Expand Up @@ -329,7 +327,7 @@ function FieldToolbarComponent(
);
return () => {
event?.unregister();
}
};
}, []);

const multipleFieldToolbarButtonClasses = classNames(
Expand Down Expand Up @@ -387,7 +385,7 @@ function FieldToolbarComponent(
multipleFieldToolbarButtonClasses
}
data-tooltip={
direction.value === "vertical"
direction === "vertical"
? "Move up"
: "Move left"
}
Expand All @@ -404,10 +402,10 @@ function FieldToolbarComponent(
<MoveLeftIcon
className={classNames({
"visual-builder__rotate--90":
direction.value === "vertical",
direction === "vertical",
[visualBuilderStyles()[
"visual-builder__rotate--90"
]]: direction.value === "vertical",
]]: direction === "vertical",
})}
disabled={disableMoveLeft}
/>
Expand All @@ -419,7 +417,7 @@ function FieldToolbarComponent(
multipleFieldToolbarButtonClasses
}
data-tooltip={
direction.value === "vertical"
direction === "vertical"
? "Move down"
: "Move right"
}
Expand All @@ -436,10 +434,10 @@ function FieldToolbarComponent(
<MoveRightIcon
className={classNames({
"visual-builder__rotate--90":
direction.value === "vertical",
direction === "vertical",
[visualBuilderStyles()[
"visual-builder__rotate--90"
]]: direction.value === "vertical",
]]: direction === "vertical",
})}
disabled={disableMoveRight}
/>
Expand Down

0 comments on commit 4588512

Please sign in to comment.