mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge pull request #373 from appwrite/refactor/input-select-search-hiding-x
Refactor: input select search hiding x
This commit is contained in:
1 file changed
+13
-9
@@ -13,7 +13,7 @@
|
||||
export let options: OptionArray;
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
export let name: string = 'elements';
|
||||
export let name = 'elements';
|
||||
export let optionalText: string | undefined = undefined;
|
||||
export let showLabel = true;
|
||||
export let placeholder = '';
|
||||
@@ -23,7 +23,7 @@
|
||||
// Input value
|
||||
export let search = '';
|
||||
// The actual selected value
|
||||
export let value: string | number | boolean;
|
||||
export let value: Option['value'];
|
||||
$: selectedOption = options.find((option) => option.value === value);
|
||||
|
||||
let element: HTMLInputElement;
|
||||
@@ -88,6 +88,8 @@
|
||||
element.value = search;
|
||||
hasFocus = false;
|
||||
}
|
||||
|
||||
$: showClearBtn = (hasFocus && search) || value;
|
||||
</script>
|
||||
|
||||
<li class="u-position-relative form-item u-stretch">
|
||||
@@ -126,13 +128,15 @@
|
||||
{/if}
|
||||
|
||||
<div class="options-list">
|
||||
<button
|
||||
class="options-list-button"
|
||||
aria-label="clear field"
|
||||
type="button"
|
||||
on:click|preventDefault={clearOption}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{#if showClearBtn}
|
||||
<button
|
||||
class="options-list-button"
|
||||
aria-label="clear field"
|
||||
type="button"
|
||||
on:click|preventDefault={clearOption}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
class="options-list-button"
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user