fix(ui): improved dropdown positioning, added rich data to corpse loot

This commit is contained in:
Joan
2026-02-07 22:55:12 +01:00
parent 0e0ac10b20
commit 6f1e8c56f2

View File

@@ -57,7 +57,10 @@ export const GameDropdown: React.FC<GameDropdownProps> = ({
if (!isOpen) return null; if (!isOpen) return null;
// Adjust position to keep within viewport // 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) // 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 // 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<GameDropdownProps> = ({
if (y + estimatedHeight > viewportHeight) { if (y + estimatedHeight > viewportHeight) {
// Flip up if space // Flip up if space
y = y - estimatedHeight; flipUp = true;
// Or just limit to bottom
if (y < 0) y = 10;
} }
} }
@@ -86,7 +87,8 @@ export const GameDropdown: React.FC<GameDropdownProps> = ({
ref={dropdownRef} ref={dropdownRef}
className={`game-dropdown-menu ${className}`} className={`game-dropdown-menu ${className}`}
style={{ style={{
top: y, top: flipUp ? 'auto' : y,
bottom: flipUp ? (window.innerHeight - y) : 'auto',
left: x, left: x,
width: width width: width
}} }}