Skip to content

Commit 0a15d81

Browse files
committed
fix: fix kanban reference selecte card
1 parent 8a3b349 commit 0a15d81

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

apps/frontend/src/lib/components/blocks/field-value/reference-field.svelte

+25-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,40 @@
22
import type { ReferenceField } from "@undb/table"
33
import ForeignRecordsPickerDropdown from "../reference/foreign-records-picker-dropdown.svelte"
44
import { Button } from "$lib/components/ui/button"
5+
import { writable } from "svelte/store"
56
67
export let value: string[] | null
78
export let field: ReferenceField
89
export let tableId: string
910
export let recordId: string | undefined
1011
11-
$: hasValue = Array.isArray(value) && value?.length > 0
12+
$: selected = writable<string[]>(value)
13+
14+
let hasValue = Array.isArray(value) && value.length > 0
15+
16+
$: selected, (hasValue = Array.isArray(value) && value.length > 0)
17+
18+
$: hasValueReactive = Array.isArray($selected) && $selected.length > 0
19+
$: if (hasValue && !hasValueReactive) {
20+
hasValue = hasValueReactive
21+
}
1222
</script>
1323

1424
<div class="flex gap-1 overflow-hidden">
15-
<ForeignRecordsPickerDropdown shouldUpdate {field} {tableId} {recordId} bind:isSelected={hasValue} let:builder>
25+
<ForeignRecordsPickerDropdown
26+
shouldUpdate
27+
onOpenChange={(open) => {
28+
if (!open) {
29+
hasValue = hasValueReactive
30+
}
31+
}}
32+
{field}
33+
{tableId}
34+
{recordId}
35+
bind:isSelected={hasValue}
36+
bind:selected
37+
let:builder
38+
>
1639
{#if hasValue}
1740
<Button size="xs" variant="link" class="px-0" builders={[builder]} on:click={(e) => e.stopPropagation()}>
1841
{value?.length} Linked Records

0 commit comments

Comments
 (0)