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} >