1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Fixed selected item highlighting bug in grid

This commit is contained in:
Romein van Buren 2023-08-26 20:39:47 +02:00
parent 1b834de091
commit a01c56ab69
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -52,7 +52,10 @@
return obj; return obj;
} }
else if ((typeof obj === 'object') && (obj !== null)) { else if ((typeof obj === 'object') && (obj !== null)) {
return Object.entries(obj).map(([ k, item ]) => { return Object.entries(obj).map(([
k,
item,
]) => {
return { ...item, [key]: k }; return { ...item, [key]: k };
}); });
} }
@ -67,7 +70,10 @@
} }
activeKey = itemKey; activeKey = itemKey;
activePath = [ ...path.slice(0, level), itemKey ]; activePath = [
...path.slice(0, level),
itemKey,
];
dispatch('select', { level, itemKey, index, path: activePath }); dispatch('select', { level, itemKey, index, path: activePath });
} }
@ -126,12 +132,17 @@
</script> </script>
{#each _items as item, index} {#each _items as item, index}
{@const selected = canSelect && pathsAreEqual(activePath, [
...path,
item[key],
])}
<tr <tr
on:click={() => select(item[key], index)} on:click={() => select(item[key], index)}
on:dblclick={() => doubleClick(item[key], index)} on:dblclick={() => doubleClick(item[key], index)}
on:contextmenu|preventDefault={evt => showContextMenu(evt, item)} on:contextmenu|preventDefault={evt => showContextMenu(evt, item)}
class:selectable={canSelect} class:selectable={canSelect}
class:selected={canSelect && pathsAreEqual(activePath, ...path, item[key])} class:selected
class:striped class:striped
> >
{#if !hideChildrenToggles} {#if !hideChildrenToggles}
@ -193,7 +204,10 @@
{hideChildrenToggles} {hideChildrenToggles}
{canSelect} {canSelect}
{canRemoveItems} {canRemoveItems}
path={[ ...path, item[key] ]} path={[
...path,
item[key],
]}
items={item.children} items={item.children}
level={level + 1} level={level + 1}
bind:activePath bind:activePath