Row parameter "expanded" not work as expected for some rows
tsctw opened this issue · comments
Hi there,
I imported svelte-gantt library to my react
project.
Please try to reproduce the bug through the rows data below. The two parents set expanded: false
.
rows: [
{
id: 'x',
label: 'x',
height: 50,
expanded: false,
children: [
{
id: 'x-sub',
label: 'x sub group',
height: 50,
children: [
{
id: 472,
label: '472',
height: 50,
},
{
id: 214,
label: '214',
height: 50,
},
{
id: 43,
label: '43',
height: 50,
},
{
id: 50,
label: '50',
height: 50,
},
],
},
],
},
{
id: 'y',
label: 'y',
height: 50,
expanded: false,
children: [
{
id: 'y-sub',
label: 'y sub group',
height: 50,
children: [
{
id: 474,
label: '474',
height: 50,
},
],
},
],
},
],
When I tried to put expanded: false
property to rows which have children, the first row with this property is not collapsed as expected because the svelte hook onMount
not renew the row.expanded
update-to-date (replace it with afterUpdate
can fix it).
Also, in my opinion you could use row.model.expanded
to check the expanded status in Table.svelte
, TableRow.svelte
and TableTreeCell.svelte
. row.expanded
not works for some unknown reason. I changed it on my local and tested, it seems to work well after the modification.
Furthermore, I got this error, might come from different chunk of codes.
It's also an unknown issue for me, but I know if we can check whether row
is empty before we use it, the problem might be solved......
svelte-gantt/src/modules/table/Table.svelte
$taskStore.ids.forEach(id => {
const task = $taskStore.entities[id];
const row = $rowStore.entities[task.model.resourceId];
$taskStore.entities[id].top = row.y + $rowPadding; -> if (row) $taskStore.entities[id].top = row.y + $rowPadding;
});
I have limited experiences on Svelte, so perhaps you have better solutions. Can you fix this bug? Or if you don't mind I can provide my solution on a new PR.
Thanks.
Thank you, your solution seems fine. I'll be doing it that way.