Fix selected item for views v1

This commit is contained in:
Adria Navarro 2025-01-23 15:26:18 +01:00
parent 9ab325596e
commit 4c48ad6526
2 changed files with 15 additions and 2 deletions

View File

@ -7,8 +7,21 @@
export let dataSet
export let value
export let onSelect
export let identifiers = ["resourceId"]
$: displayDatasourceName = $datasources.list.length > 1
function isSelected(entry) {
if (!identifiers.length) {
return false
}
for (const identifier of identifiers) {
if (entry[identifier] !== value?.[identifier]) {
return false
}
}
return true
}
</script>
{#if dividerState}
@ -24,8 +37,7 @@
{#each dataSet as data}
<li
class="spectrum-Menu-item"
class:is-selected={value?.resourceId === data.resourceId &&
value?.type === data.type}
class:is-selected={isSelected(data) && value?.type === data.type}
role="option"
aria-selected="true"
tabindex="0"

View File

@ -291,6 +291,7 @@
dataSet={views}
{value}
onSelect={handleSelected}
identifiers={["tableId", "name"]}
/>
{/if}
{#if queries?.length}