From b0f31aaf150e88044e3c5185f0fe47ade247b265 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 16 Apr 2021 09:01:21 +0100 Subject: [PATCH] Allow selects to support no placeholder option --- packages/bbui/src/Form/Core/Select.svelte | 7 +++---- packages/bbui/src/Form/Select.svelte | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/bbui/src/Form/Core/Select.svelte b/packages/bbui/src/Form/Core/Select.svelte index 44366db392..cae61cfa4f 100644 --- a/packages/bbui/src/Form/Core/Select.svelte +++ b/packages/bbui/src/Form/Core/Select.svelte @@ -4,7 +4,7 @@ export let value = null export let fieldId = null - export let placeholder = null + export let placeholder = "Choose an option" export let disabled = false export let error = null export let options = [] @@ -13,13 +13,12 @@ const dispatch = createEventDispatcher() let open = false - $: placeholderText = placeholder || "Choose an option" $: isNull = value == null || value === "" $: selectedOption = options.find(option => getOptionValue(option) === value) $: selectedLabel = selectedOption ? getOptionLabel(selectedOption) : placeholderText - $: fieldText = isNull ? placeholderText : selectedLabel + $: fieldText = isNull ? placeholder || "Choose an option" : selectedLabel const selectOption = value => { dispatch("change", value) @@ -37,6 +36,6 @@ {getOptionLabel} {getOptionValue} isPlaceholder={isNull} - placeholderOption={placeholderText} + placeholderOption={placeholder} isOptionSelected={option => option === value} onSelectOption={selectOption} /> diff --git a/packages/bbui/src/Form/Select.svelte b/packages/bbui/src/Form/Select.svelte index f412df6ce0..731011c21e 100644 --- a/packages/bbui/src/Form/Select.svelte +++ b/packages/bbui/src/Form/Select.svelte @@ -8,7 +8,7 @@ export let disabled = false export let labelPosition = "above" export let error = null - export let placeholder = null + export let placeholder = "Choose an option" export let options = [] export let getOptionLabel = option => option export let getOptionValue = option => option