From 516d163ea2f6683f7dc629e2e1f5f3c18f615313 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 10 May 2022 13:16:21 +0100 Subject: [PATCH] Close picker on click of listbox --- packages/bbui/src/Form/Core/Picker.svelte | 187 +++++++++++----------- 1 file changed, 94 insertions(+), 93 deletions(-) diff --git a/packages/bbui/src/Form/Core/Picker.svelte b/packages/bbui/src/Form/Core/Picker.svelte index 143536a60a..2585f11939 100644 --- a/packages/bbui/src/Form/Core/Picker.svelte +++ b/packages/bbui/src/Form/Core/Picker.svelte @@ -43,7 +43,7 @@ return } searchTerm = null - open = true + open = !open } const getSortedOptions = (options, getLabel, sort) => { @@ -71,105 +71,73 @@ } - -{#if open} -
(open = false)} - transition:fly|local={{ y: -20, duration: 200 }} - class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" - class:auto-width={autoWidth} - > - {#if autocomplete} - (searchTerm = event.detail)} - {disabled} - placeholder="Search" - /> - {/if} -
    - {#if placeholderOption} -
  • onSelectOption(null)} - > - {placeholderOption} - -
  • + + {#if open} +
    + {#if autocomplete} + (searchTerm = event.detail)} + {disabled} + placeholder="Search" + /> {/if} - {#if filteredOptions.length} - {#each filteredOptions as option, idx} +
      + {#if placeholderOption}
    • onSelectOption(getOptionValue(option, idx))} + on:click={() => onSelectOption(null)} > - {#if getOptionIcon(option, idx)} - - icon - - {/if} - - {getOptionLabel(option, idx)} - + {placeholderOption}
    • - {/each} - {/if} -
    -
    -{/if} + {/if} + {#if filteredOptions.length} + {#each filteredOptions as option, idx} +
  • onSelectOption(getOptionValue(option, idx))} + > + {#if getOptionIcon(option, idx)} + + icon + + {/if} + + {getOptionLabel(option, idx)} + + +
  • + {/each} + {/if} +
+
+ {/if} +