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

View File

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