From 3f1ec54fe99a6ebc26154c707bc8720a9e4c919c Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:38:11 +0100 Subject: [PATCH 1/2] Relationship picker searching enhancement (#11639) * Search for initially set value and add to options * Only append option if needed * Handle change * Open dropdown on search * Avoid duplicates * Add client side search * lint * Offset popover * refactor * Refactor * refactor --- .../bbui/src/Actions/position_dropdown.js | 3 +- .../bbui/src/Form/Core/Multiselect.svelte | 6 + packages/bbui/src/Form/Core/Picker.svelte | 4 + packages/bbui/src/Form/Core/Select.svelte | 8 +- packages/bbui/src/Popover/Popover.svelte | 2 + packages/client/manifest.json | 4 +- .../app/forms/RelationshipField.svelte | 195 ++++++++++++++++-- packages/frontend-core/src/index.js | 1 + 8 files changed, 200 insertions(+), 23 deletions(-) diff --git a/packages/bbui/src/Actions/position_dropdown.js b/packages/bbui/src/Actions/position_dropdown.js index cc169eac09..f2018272f6 100644 --- a/packages/bbui/src/Actions/position_dropdown.js +++ b/packages/bbui/src/Actions/position_dropdown.js @@ -18,6 +18,7 @@ export default function positionDropdown(element, opts) { useAnchorWidth, offset = 5, customUpdate, + offsetBelow, } = opts if (!anchor) { return @@ -47,7 +48,7 @@ export default function positionDropdown(element, opts) { styles.top = anchorBounds.top - elementBounds.height - offset styles.maxHeight = maxHeight || 240 } else { - styles.top = anchorBounds.bottom + offset + styles.top = anchorBounds.bottom + (offsetBelow || offset) styles.maxHeight = maxHeight || window.innerHeight - anchorBounds.bottom - 20 } diff --git a/packages/bbui/src/Form/Core/Multiselect.svelte b/packages/bbui/src/Form/Core/Multiselect.svelte index ea9b5858f5..8816da33c4 100644 --- a/packages/bbui/src/Form/Core/Multiselect.svelte +++ b/packages/bbui/src/Form/Core/Multiselect.svelte @@ -17,6 +17,9 @@ export let fetchTerm = null export let useFetch = false export let customPopoverHeight + export let customPopoverOffsetBelow + export let customPopoverMaxHeight + export let open = false const dispatch = createEventDispatcher() @@ -88,6 +91,7 @@ isPlaceholder={!arrayValue.length} {autocomplete} bind:fetchTerm + bind:open {useFetch} {isOptionSelected} {getOptionLabel} @@ -96,4 +100,6 @@ {sort} {autoWidth} {customPopoverHeight} + {customPopoverOffsetBelow} + {customPopoverMaxHeight} /> diff --git a/packages/bbui/src/Form/Core/Picker.svelte b/packages/bbui/src/Form/Core/Picker.svelte index c75a996cfe..9b90c1a865 100644 --- a/packages/bbui/src/Form/Core/Picker.svelte +++ b/packages/bbui/src/Form/Core/Picker.svelte @@ -38,6 +38,8 @@ export let fetchTerm = null export let useFetch = false export let customPopoverHeight + export let customPopoverOffsetBelow + export let customPopoverMaxHeight export let align = "left" export let footer = null export let customAnchor = null @@ -150,7 +152,9 @@ on:close={() => (open = false)} useAnchorWidth={!autoWidth} maxWidth={autoWidth ? 400 : null} + maxHeight={customPopoverMaxHeight} customHeight={customPopoverHeight} + offsetBelow={customPopoverOffsetBelow} >
option === value} diff --git a/packages/bbui/src/Popover/Popover.svelte b/packages/bbui/src/Popover/Popover.svelte index 13a6822853..4c4b818440 100644 --- a/packages/bbui/src/Popover/Popover.svelte +++ b/packages/bbui/src/Popover/Popover.svelte @@ -19,6 +19,7 @@ export let useAnchorWidth = false export let dismissible = true export let offset = 5 + export let offsetBelow export let customHeight export let animate = true export let customZindex @@ -89,6 +90,7 @@ maxWidth, useAnchorWidth, offset, + offsetBelow, customUpdate: handlePostionUpdate, }} use:clickOutside={{ diff --git a/packages/client/manifest.json b/packages/client/manifest.json index d91a71853e..229d344d55 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -3647,9 +3647,9 @@ }, { "type": "boolean", - "label": "Autocomplete", + "label": "Search", "key": "autocomplete", - "defaultValue": false + "defaultValue": true }, { "type": "boolean", diff --git a/packages/client/src/components/app/forms/RelationshipField.svelte b/packages/client/src/components/app/forms/RelationshipField.svelte index 0c8b076a67..ecbbfcde6a 100644 --- a/packages/client/src/components/app/forms/RelationshipField.svelte +++ b/packages/client/src/components/app/forms/RelationshipField.svelte @@ -1,6 +1,11 @@ {#if fieldState} - option._id} - {placeholder} - sort={true} - /> +
+ option._id} + {placeholder} + customPopoverOffsetBelow={autocomplete ? 32 : null} + customPopoverMaxHeight={autocomplete ? 240 : null} + sort={true} + /> + {#if autocomplete} + + {/if} +
{/if}
+ + diff --git a/packages/frontend-core/src/index.js b/packages/frontend-core/src/index.js index 01bf05c69e..b0afc0c25d 100644 --- a/packages/frontend-core/src/index.js +++ b/packages/frontend-core/src/index.js @@ -1,5 +1,6 @@ export { createAPIClient } from "./api" export { fetchData } from "./fetch/fetchData" +export { Utils } from "./utils" export * as Constants from "./constants" export * from "./stores" export * from "./utils" From 066d8ff8d3f7a6e431bc68688e8ad955166aa352 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 6 Sep 2023 15:38:30 +0000 Subject: [PATCH 2/2] Bump version to 2.9.39-alpha.10 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 07de18b1d3..dc6caf3326 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.9.39-alpha.9", + "version": "2.9.39-alpha.10", "npmClient": "yarn", "packages": [ "packages/*"