0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Fixed popover "right" position in AdminX (#18549)

refs https://github.com/TryGhost/Product/issues/3832

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at babb461</samp>

This pull request enhances the popover component in the
`admin-x-settings` app. It fixes a bug with the alignment of the popover
and refactors the style object for better readability and
maintainability.
This commit is contained in:
Jono M 2023-10-10 07:34:35 +01:00 committed by GitHub
parent dcb9bfa7fc
commit 7f2dc6e5fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,7 +36,7 @@ const Popover: React.FC<PopoverProps> = ({
x -= parentRect.x;
y -= parentRect.y;
const finalX = (position === 'left') ? x : x - width;
const finalX = (position === 'left') ? x : window.innerWidth - (x + width);
setOpen(true);
setPositionX(finalX);
setPositionY(y + height);
@ -46,10 +46,15 @@ const Popover: React.FC<PopoverProps> = ({
};
const style: React.CSSProperties = {
top: `${positionY}px`,
left: `${positionX}px`
top: `${positionY}px`
};
if (position === 'left') {
style.left = `${positionX}px`;
} else {
style.right = `${positionX}px`;
}
const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => {
if (e.target === e.currentTarget) {
setOpen(false);