fix input focus loss when error state changes
always wrap in fieldset to keep DOM structure stable
This commit is contained in:
parent
9787af9c42
commit
362db1238f
1 changed files with 40 additions and 99 deletions
|
|
@ -99,8 +99,7 @@
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if label || error}
|
<fieldset class={fieldsetClasses}>
|
||||||
<fieldset class={fieldsetClasses}>
|
|
||||||
{#if label}
|
{#if label}
|
||||||
<Label.Root class="label" for={restProps.id}>
|
<Label.Root class="label" for={restProps.id}>
|
||||||
{label}
|
{label}
|
||||||
|
|
@ -172,65 +171,7 @@
|
||||||
{#if error}
|
{#if error}
|
||||||
<span class="error">{error}</span>
|
<span class="error">{error}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{:else if hasWrapper}
|
|
||||||
<div class={inputClasses}>
|
|
||||||
{#if leftIcon}
|
|
||||||
<span class="iconLeft">
|
|
||||||
<Icon name={leftIcon} size={16} />
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<input
|
|
||||||
bind:value
|
|
||||||
{type}
|
|
||||||
{placeholder}
|
|
||||||
{disabled}
|
|
||||||
{readonly}
|
|
||||||
{required}
|
|
||||||
maxlength={maxLength}
|
|
||||||
data-1p-ignore={no1password}
|
|
||||||
onblur={handleBlur}
|
|
||||||
onfocus={handleFocus}
|
|
||||||
oninput={handleInput}
|
|
||||||
{...restProps}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{#if rightIcon}
|
|
||||||
<span class="iconRight">
|
|
||||||
<Icon name={rightIcon} size={16} />
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if validationIcon}
|
|
||||||
<span class="validationIcon {validationState}">
|
|
||||||
<Icon name={validationIcon} size={16} />
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if showCounter}
|
|
||||||
<span class="counter" class:warning={charsRemaining !== undefined && charsRemaining <= 5}>
|
|
||||||
{charsRemaining !== undefined ? charsRemaining : currentCount}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<input
|
|
||||||
bind:value
|
|
||||||
class={inputClasses}
|
|
||||||
{type}
|
|
||||||
{placeholder}
|
|
||||||
{disabled}
|
|
||||||
{readonly}
|
|
||||||
{required}
|
|
||||||
maxlength={maxLength}
|
|
||||||
data-1p-ignore={no1password}
|
|
||||||
onblur={handleBlur}
|
|
||||||
onfocus={handleFocus}
|
|
||||||
oninput={handleInput}
|
|
||||||
{...restProps}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@use '$src/themes/spacing' as *;
|
@use '$src/themes/spacing' as *;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue