Skip to content

Commit ac898b4

Browse files
committed
fixed an issue caused by autowidth
1 parent 2ecc805 commit ac898b4

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

packages/uui-input/lib/uui-input.element.ts

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FormControlMixin, LabelMixin } from '@umbraco-ui/uui-base/lib/mixins';
22
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
3-
import { css, html, LitElement, nothing, PropertyValueMap } from 'lit';
3+
import { css, html, LitElement, PropertyValueMap } from 'lit';
44
import { property, query } from 'lit/decorators.js';
55
import { ifDefined } from 'lit/directives/if-defined.js';
66

@@ -401,34 +401,41 @@ export class UUIInputElement extends FormControlMixin(
401401
render() {
402402
return html`
403403
${this.renderPrepend()}
404-
<div id="control">
405-
<input
406-
id="input"
407-
.type=${this.type}
408-
.value=${this.value as string}
409-
.name=${this.name}
410-
pattern=${ifDefined(this.pattern)}
411-
min=${ifDefined(this.min)}
412-
max=${ifDefined(this.max)}
413-
step=${ifDefined(this.step)}
414-
spellcheck=${this.spellcheck}
415-
autocomplete=${ifDefined(this.autocomplete as any)}
416-
placeholder=${ifDefined(this.placeholder)}
417-
aria-label=${ifDefined(this.label)}
418-
inputmode=${ifDefined(this.inputMode)}
419-
?disabled=${this.disabled}
420-
?autofocus=${this.autofocus}
421-
?required=${this.required}
422-
?readonly=${this.readonly}
423-
@input=${this.onInput}
424-
@change=${this.onChange} />
425-
${this.autoWidth ? this.renderAutoWidth() : nothing}
426-
</div>
404+
${this.autoWidth ? this.renderInputWithAutoWidth() : this.renderInput()}
427405
${this.renderAppend()}
428406
`;
429407
}
430408

431-
private renderAutoWidth() {
409+
private renderInputWithAutoWidth() {
410+
html`<div id="control">
411+
${this.renderInput()}${this.renderAutoWidthBackground()}
412+
</div>`;
413+
}
414+
415+
renderInput() {
416+
return html`<input
417+
id="input"
418+
.type=${this.type}
419+
.value=${this.value as string}
420+
.name=${this.name}
421+
pattern=${ifDefined(this.pattern)}
422+
min=${ifDefined(this.min)}
423+
max=${ifDefined(this.max)}
424+
step=${ifDefined(this.step)}
425+
spellcheck=${this.spellcheck}
426+
autocomplete=${ifDefined(this.autocomplete as any)}
427+
placeholder=${ifDefined(this.placeholder)}
428+
aria-label=${ifDefined(this.label)}
429+
inputmode=${ifDefined(this.inputMode)}
430+
?disabled=${this.disabled}
431+
?autofocus=${this.autofocus}
432+
?required=${this.required}
433+
?readonly=${this.readonly}
434+
@input=${this.onInput}
435+
@change=${this.onChange} />`;
436+
}
437+
438+
private renderAutoWidthBackground() {
432439
return html` <div id="auto" aria-hidden="true">${this.renderText()}</div>`;
433440
}
434441

0 commit comments

Comments
 (0)