diff --git a/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte b/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte index 88eb0730ac..ee2adf5848 100644 --- a/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte +++ b/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte @@ -164,7 +164,6 @@ user-select: none; } .arrow { - /*border-right: 2px solid var(--spectrum-global-color-blue-400);*/ position: absolute; right: 0; top: 0; @@ -202,7 +201,7 @@ top: 0; } .option { - flex: 0 0 var(--row-height); + flex: 0 0 var(--default-row-height); padding: 0 var(--cell-padding); display: flex; flex-direction: row; diff --git a/packages/frontend-core/src/components/sheet/cells/RelationshipCell.svelte b/packages/frontend-core/src/components/sheet/cells/RelationshipCell.svelte index f4ade23a56..60bf9208df 100644 --- a/packages/frontend-core/src/components/sheet/cells/RelationshipCell.svelte +++ b/packages/frontend-core/src/components/sheet/cells/RelationshipCell.svelte @@ -13,7 +13,8 @@ export let invertX = false export let invertY = false - const { API } = getContext("sheet") + const { API, dispatch } = getContext("sheet") + const color = getColor(0) let isOpen = false let searchResults @@ -23,11 +24,9 @@ let primaryDisplay let candidateIndex let lastSearchId - let results $: oneRowOnly = schema?.relationshipType === "one-to-many" $: editable = focused && !readonly - $: results = getResults(searchResults, value) $: lookupMap = buildLookupMap(value, isOpen) $: search(searchString) $: { @@ -94,10 +93,12 @@ } // Sort and process results - searchResults = results.rows?.map(row => ({ - ...row, - primaryDisplay: row[primaryDisplay], - })) + searchResults = sortRows( + results.rows?.map(row => ({ + ...row, + primaryDisplay: row[primaryDisplay], + })) + ) candidateIndex = searchResults?.length ? 0 : null lastSearchString = searchString }, 250) @@ -112,17 +113,9 @@ }) } - // Generates the list of results to show inside the dropdown - const getResults = (searchResults, value) => { - return searchString ? sortRows(searchResults) : sortRows(value) - } - const open = async () => { isOpen = true - // Ensure results are properly reset - results = sortRows(value) - // Fetch definition if required if (!definition) { definition = await API.fetchTableDefinition(schema.tableId) @@ -196,6 +189,14 @@ close() } + const showRelationship = async id => { + const relatedRow = await API.fetchRow({ + tableId: schema.tableId, + rowId: id, + }) + dispatch("edit-row", relatedRow) + } + onMount(() => { api = { focus: open, @@ -205,74 +206,136 @@ }) -