()
| 168 | |
| 169 | useLayoutEffect(() => { |
| 170 | const updateDropdownPosition = () => { |
| 171 | if (isOpened && buttonRef.current) { |
| 172 | const buttonRect = buttonRef.current.getBoundingClientRect(); |
| 173 | setDropdownPosition({ |
| 174 | top: buttonRect.bottom + window.scrollY + 8, |
| 175 | left: buttonRect.left + window.scrollX, |
| 176 | width: buttonRect.width, |
| 177 | }); |
| 178 | } |
| 179 | }; |
| 180 | |
| 181 | updateDropdownPosition(); |
| 182 | window.addEventListener('resize', updateDropdownPosition); |