Skip to content

Commit af8b738

Browse files
loivseniOvergaard
andauthored
fix: small bugfix for auto width not rendering (#578)
* small bugfix for auto width not rendering * Additional margin option, useful when type=number --------- Co-authored-by: Jacob Overgaard <[email protected]>
1 parent 8459fdb commit af8b738

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export class UUIInputElement extends FormControlMixin(
5858
var(--uui-input-border-color, var(--uui-color-border));
5959
6060
--uui-button-height: 100%;
61+
--auto-width-text-margin-right: 0;
62+
--auto-width-text-margin-left: 0;
6163
}
6264
6365
#control {
@@ -75,6 +77,8 @@ export class UUIInputElement extends FormControlMixin(
7577
z-index: -1;
7678
height: 0px;
7779
padding: 0 var(--uui-size-space-3);
80+
margin: 0 var(--auto-width-text-margin-right) 0
81+
var(--auto-width-text-margin-left);
7882
}
7983
8084
:host([auto-width]) #input {
@@ -407,7 +411,7 @@ export class UUIInputElement extends FormControlMixin(
407411
}
408412

409413
private renderInputWithAutoWidth() {
410-
html`<div id="control">
414+
return html`<div id="control">
411415
${this.renderInput()}${this.renderAutoWidthBackground()}
412416
</div>`;
413417
}

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export const AutoWidth: Story = {
314314
.name=${props.name}
315315
.placeholder=${props.placeholder}
316316
.value=${props.value}
317-
.autoWidth=${props.autoWidth}>
317+
?auto-width=${props.autoWidth}>
318318
</uui-input>
319319
<br /><br />
320320
<uui-input
@@ -329,15 +329,31 @@ export const AutoWidth: Story = {
329329
.name=${props.name}
330330
.placeholder=${props.placeholder}
331331
.value=${props.value}
332-
.autoWidth=${props.autoWidth}>
332+
?auto-width=${props.autoWidth}>
333333
<uui-input
334334
slot="prepend"
335335
placeholder="Prepend auto-width"
336-
.autoWidth=${props.autoWidth}></uui-input>
336+
?auto-width=${props.autoWidth}></uui-input>
337337
<uui-input
338338
slot="append"
339339
placeholder="Append auto-width false"></uui-input>
340-
</uui-input>`,
340+
</uui-input>
341+
342+
<br /><br />
343+
<uui-input
344+
.min=${props.min}
345+
.max=${props.max}
346+
.step=${props.step}
347+
.disabled=${props.disabled}
348+
.readonly=${props.readonly}
349+
.error=${props.error}
350+
.label=${props.label}
351+
.type=${props.type}
352+
.name=${props.name}
353+
style="--auto-width-text-margin-right: 50px"
354+
placeholder="--auto-width-text-margin-right: 50px"
355+
.value=${props.value}
356+
?auto-width=${props.autoWidth}></uui-input>`,
341357
args: {
342358
autoWidth: true,
343359
placeholder: 'Start typing...',

0 commit comments

Comments
 (0)