diff --git a/pwa/src/components/common/GameDropdown.tsx b/pwa/src/components/common/GameDropdown.tsx index a80a20e..86c0625 100644 --- a/pwa/src/components/common/GameDropdown.tsx +++ b/pwa/src/components/common/GameDropdown.tsx @@ -57,7 +57,10 @@ export const GameDropdown: React.FC = ({ if (!isOpen) return null; // Adjust position to keep within viewport - let { x, y } = position; + // Default offset of -10 to center mouse over menu + let x = position.x - 10; + let y = position.y - 10; + let flipUp = false; // Simple adjustment logic (can be improved with measuring ref) // We'll trust the parent passed reasonable coords, but ensure it doesn't go off-screen right/bottom @@ -75,9 +78,7 @@ export const GameDropdown: React.FC = ({ if (y + estimatedHeight > viewportHeight) { // Flip up if space - y = y - estimatedHeight; - // Or just limit to bottom - if (y < 0) y = 10; + flipUp = true; } } @@ -86,7 +87,8 @@ export const GameDropdown: React.FC = ({ ref={dropdownRef} className={`game-dropdown-menu ${className}`} style={{ - top: y, + top: flipUp ? 'auto' : y, + bottom: flipUp ? (window.innerHeight - y) : 'auto', left: x, width: width }}