fix children breaking parent interactivity
This commit is contained in:
@@ -99,8 +99,7 @@ local function isPointInElement(element, x, y)
|
|||||||
local overflowY = current.overflowY or current.overflow
|
local overflowY = current.overflowY or current.overflow
|
||||||
|
|
||||||
-- Check if parent clips content (overflow: hidden, scroll, auto)
|
-- Check if parent clips content (overflow: hidden, scroll, auto)
|
||||||
if overflowX == "hidden" or overflowX == "scroll" or overflowX == "auto" or
|
if overflowX == "hidden" or overflowX == "scroll" or overflowX == "auto" or overflowY == "hidden" or overflowY == "scroll" or overflowY == "auto" then
|
||||||
overflowY == "hidden" or overflowY == "scroll" or overflowY == "auto" then
|
|
||||||
-- Check if point is outside parent's clipping region
|
-- Check if point is outside parent's clipping region
|
||||||
local parentX = current.x + current.padding.left
|
local parentX = current.x + current.padding.left
|
||||||
local parentY = current.y + current.padding.top
|
local parentY = current.y + current.padding.top
|
||||||
@@ -128,12 +127,32 @@ function GuiState.getTopElementAt(x, y)
|
|||||||
return nil
|
return nil
|
||||||
end
|
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)
|
-- Traverse from highest to lowest z-index (reverse order)
|
||||||
for i = #GuiState._zIndexOrderedElements, 1, -1 do
|
for i = #GuiState._zIndexOrderedElements, 1, -1 do
|
||||||
local element = GuiState._zIndexOrderedElements[i]
|
local element = GuiState._zIndexOrderedElements[i]
|
||||||
|
|
||||||
-- Check if point is inside this element
|
-- Check if point is inside this element
|
||||||
if isPointInElement(element, x, y) then
|
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
|
return element
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user