fix children breaking parent interactivity

This commit is contained in:
Michael Freno
2025-11-06 10:51:07 -05:00
parent 04480e00ec
commit 8a12a5e33d

View File

@@ -99,8 +99,7 @@ local function isPointInElement(element, x, y)
local overflowY = current.overflowY or current.overflow
-- Check if parent clips content (overflow: hidden, scroll, auto)
if overflowX == "hidden" or overflowX == "scroll" or overflowX == "auto" or
overflowY == "hidden" or overflowY == "scroll" or overflowY == "auto" then
if overflowX == "hidden" or overflowX == "scroll" or overflowX == "auto" or overflowY == "hidden" or overflowY == "scroll" or overflowY == "auto" then
-- Check if point is outside parent's clipping region
local parentX = current.x + current.padding.left
local parentY = current.y + current.padding.top
@@ -128,12 +127,32 @@ function GuiState.getTopElementAt(x, y)
return nil
end
-- Helper function to find the first interactive ancestor (including self)
local function findInteractiveAncestor(elem)
local current = elem
while current do
-- An element is interactive if it has a callback or themeComponent
if current.callback or current.themeComponent then
return current
end
current = current.parent
end
return nil
end
-- Traverse from highest to lowest z-index (reverse order)
for i = #GuiState._zIndexOrderedElements, 1, -1 do
local element = GuiState._zIndexOrderedElements[i]
-- Check if point is inside this element
if isPointInElement(element, x, y) then
-- Return the first interactive ancestor (or the element itself if interactive)
local interactive = findInteractiveAncestor(element)
if interactive then
return interactive
end
-- If no interactive ancestor, return the element itself
-- This preserves backward compatibility for non-interactive overlays
return element
end
end