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:
parent
dcb9bfa7fc
commit
7f2dc6e5fa
1 changed files with 8 additions and 3 deletions
|
@ -36,7 +36,7 @@ const Popover: React.FC<PopoverProps> = ({
|
||||||
x -= parentRect.x;
|
x -= parentRect.x;
|
||||||
y -= parentRect.y;
|
y -= parentRect.y;
|
||||||
|
|
||||||
const finalX = (position === 'left') ? x : x - width;
|
const finalX = (position === 'left') ? x : window.innerWidth - (x + width);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
setPositionX(finalX);
|
setPositionX(finalX);
|
||||||
setPositionY(y + height);
|
setPositionY(y + height);
|
||||||
|
@ -46,10 +46,15 @@ const Popover: React.FC<PopoverProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const style: React.CSSProperties = {
|
const style: React.CSSProperties = {
|
||||||
top: `${positionY}px`,
|
top: `${positionY}px`
|
||||||
left: `${positionX}px`
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (position === 'left') {
|
||||||
|
style.left = `${positionX}px`;
|
||||||
|
} else {
|
||||||
|
style.right = `${positionX}px`;
|
||||||
|
}
|
||||||
|
|
||||||
const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
if (e.target === e.currentTarget) {
|
if (e.target === e.currentTarget) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue