fire onChange event on clear button (#611)

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-12-13 10:06:19 +01:00 committed by GitHub
parent 12f66bc433
commit 438292bebf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,14 +28,14 @@
export let value: string | undefined = undefined export let value: string | undefined = undefined
export let placeholder: string = 'placeholder' export let placeholder: string = 'placeholder'
let textHTML: HTMLElement let textHTML: HTMLInputElement
</script> </script>
<div class="flex-between editbox" style={width ? 'width: ' + width : ''} on:click={() => textHTML.focus()}> <div class="flex-between editbox" style={width ? 'width: ' + width : ''} on:click={() => textHTML.focus()}>
<div class="mr-2"><Icon {icon} size={'small'} /></div> <div class="mr-2"><Icon {icon} size={'small'} /></div>
<input bind:this={textHTML} type="text" bind:value {placeholder} on:change/> <input bind:this={textHTML} type="text" bind:value {placeholder} on:change/>
{#if value} {#if value}
<div class="ml-2 btn" on:click={() => { value = '' }}> <div class="ml-2 btn" on:click={() => { textHTML.value = ''; textHTML.dispatchEvent(new Event('change')) }}>
<Tooltip label={ui.string.Clear}> <Tooltip label={ui.string.Clear}>
<div class="scale-75"><Icon icon={IconClose} size={'small'} /></div> <div class="scale-75"><Icon icon={IconClose} size={'small'} /></div>
</Tooltip> </Tooltip>