Fix EditBox keep same width if control is reused with different props (#578)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2021-12-08 16:07:56 +07:00 committed by GitHub
parent a55b475d6f
commit 6f41a078da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,7 @@
-->
<script lang="ts">
import { createEventDispatcher, onMount } from 'svelte'
import { createEventDispatcher, onMount, afterUpdate } from 'svelte'
import type { IntlString, Asset } from '@anticrm/platform'
import type { AnySvelteComponent } from '../types'
import Label from './Label.svelte'
@ -36,7 +36,7 @@
$: style = maxWidth ? `max-width: ${maxWidth};` : ''
function computeSize(t: EventTarget | null) {
function computeSize (t: EventTarget | null) {
const target = t as HTMLInputElement
const value = target.value
text.innerHTML = (value === '' ? placeholder : value).replaceAll(' ', '&nbsp;')
@ -51,6 +51,12 @@
}
computeSize(input)
})
afterUpdate(() => {
computeSize(input)
})
</script>
<div class="container" on:click={() => { input.focus() }}>