fix(dashboard): take hidden items into account when calculating padding. Fixes #194

This commit is contained in:
Folke Lemaitre 2024-12-03 09:57:36 +01:00
parent 0df7a08b01
commit 736ce447e8
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -497,18 +497,25 @@ function D:resolve(item, results, parent)
first_child = first_child + 1
end
-- correct first/last taking hidden items into account
local first, last = first_child, #results
for c = first_child, #results do
first = first or not results[c].hidden and c or nil
last = not results[c].hidden and c or last
end
if item.gap then -- add padding between child items
for i = first_child, #results - 1 do
for i = first, last - 1 do
results[i].padding = item.gap
end
end
if item.padding then -- add padding to the first and last child items
local padding = self:padding(item)
if padding[2] > 0 and results[first_child] then
results[first_child].padding = { 0, padding[2] }
if padding[2] > 0 and results[first] then
results[first].padding = { 0, padding[2] }
end
if padding[1] > 0 and results[#results] then
results[#results].padding = { padding[1], 0 }
if padding[1] > 0 and results[last] then
results[last].padding = { padding[1], 0 }
end
end
elseif type(item) ~= "table" then