Merge branch 'main' of https://github.com/formbricks/formbricks into feat-resetpassword

This commit is contained in:
Piyush Gupta
2025-07-01 10:29:50 +05:30

View File

@@ -21,16 +21,27 @@ export const OptionsSwitch = ({
const [highlightStyle, setHighlightStyle] = useState({});
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (containerRef.current) {
const activeElement = containerRef.current.querySelector(`[data-value="${currentOption}"]`);
if (activeElement) {
const { offsetLeft, offsetWidth } = activeElement as HTMLElement;
setHighlightStyle({
left: `${offsetLeft}px`,
width: `${offsetWidth}px`,
});
const updateHighlight = () => {
if (containerRef.current) {
const activeElement = containerRef.current.querySelector(`[data-value="${currentOption}"]`);
if (activeElement) {
const { offsetLeft, offsetWidth } = activeElement as HTMLElement;
setHighlightStyle({
left: `${offsetLeft}px`,
width: `${offsetWidth}px`,
});
} else {
// Hide highlight if no matching element found
setHighlightStyle({ opacity: 0 });
}
}
}
};
// Initial call
updateHighlight();
// Listen to resize
window.addEventListener("resize", updateHighlight);
return () => window.removeEventListener("resize", updateHighlight);
}, [currentOption]);
return (