Skip to content

Commit

Permalink
simpler solution for highlights following you around
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglass committed Jul 17, 2024
1 parent 9f9fb5b commit d2a716f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
1 change: 0 additions & 1 deletion packages/journey-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ export const run = async (props: RunProps): Promise<RunOutput> => {
if (props.ui != null) {
uiElement = document.createElement("journey-manager");
uiElement.style.zIndex = 1000;
uiElement.style.position = "absolute";
uiElement.config = props.ui;
uiElement.client = client;
const handleAction = (ev: any): void => {
Expand Down
21 changes: 1 addition & 20 deletions packages/journey-manager/src/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,6 @@ const Highlight: FunctionComponent<{ element: HTMLElement }> = ({
const ref = useRef<HTMLDivElement | null>(null);
const [pos, setPos] = useState<{ x: number; y: number } | null>(null);

const ancestors: Element[] = ((element: HTMLElement) => {
const ancestors: Element[] = [];
while (element.parentNode instanceof HTMLElement) {
ancestors.push(element.parentNode);
element = element.parentNode;
}
return ancestors;
})(element);

useEffect(() => {
if (ref.current != null) {
const highlight = ref.current;
Expand All @@ -420,17 +411,7 @@ const Highlight: FunctionComponent<{ element: HTMLElement }> = ({
});
};

const cleanupAutoUpdate = autoUpdate(element, highlight, moveHighlight);
const resizeObserver = new ResizeObserver(moveHighlight);

ancestors.forEach((ancestor) => {
resizeObserver.observe(ancestor);
});

return () => {
resizeObserver.disconnect();
cleanupAutoUpdate();
};
return autoUpdate(element, highlight, moveHighlight);
}
}, [element]);
return (
Expand Down

0 comments on commit d2a716f

Please sign in to comment.