Skip to content

Commit 8ffcab7

Browse files
committed
fix: properly forward the label to the textfield in autocomplete
1 parent 735560d commit 8ffcab7

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/autocomplete/src/Autocomplete.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
>
2323
<slot>
2424
<Textfield
25+
{label}
2526
bind:value={text}
2627
{...prefixFilter($$restProps, 'textfield$')}
2728
/>
@@ -114,6 +115,7 @@
114115
export let getOptionLabel: (option: any) => string = (option: any) =>
115116
option == null ? '' : `${option}`;
116117
export let text = getOptionLabel(value);
118+
export let label: string | undefined = undefined;
117119
export let toggle = false;
118120
export let combobox = false;
119121
export let clearOnBlur = !combobox;

packages/autocomplete/src/Autocomplete.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export declare class AutocompleteComponentDev extends Component {
1919
| 'getOptionDisabled'
2020
| 'getOptionLabel'
2121
| 'text'
22+
| 'label'
2223
| 'toggle'
2324
| 'combobox'
2425
| 'clearOnBlur'
@@ -33,6 +34,7 @@ export declare class AutocompleteComponentDev extends Component {
3334
} & {
3435
[k in keyof ListComponentDev['$$prop_def'] as `list\$${k}`]?: ListComponentDev['$$prop_def'][k];
3536
} & {
37+
textfield$label?: never;
3638
textfield$value?: never;
3739
} & Component['$$prop_def'];
3840
}

packages/site/src/routes/demo/autocomplete/_Manual.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
bind:text={textStandard}
77
class="demo-autocomplete-width"
88
>
9-
<Textfield bind:value={textStandard} />
9+
<Textfield label="Fruit" bind:value={textStandard} />
1010
</Autocomplete>
1111

1212
<pre class="status">Selected: {valueStandard || ''}</pre>
@@ -19,7 +19,7 @@
1919
bind:text={textFilled}
2020
class="demo-autocomplete-width"
2121
>
22-
<Textfield bind:value={textFilled} variant="filled" />
22+
<Textfield label="Fruit" bind:value={textFilled} variant="filled" />
2323
</Autocomplete>
2424

2525
<pre class="status">Selected: {valueFilled || ''}</pre>
@@ -32,7 +32,7 @@
3232
bind:text={textOutlined}
3333
class="demo-autocomplete-width"
3434
>
35-
<Textfield bind:value={textOutlined} variant="outlined" />
35+
<Textfield label="Fruit" bind:value={textOutlined} variant="outlined" />
3636
</Autocomplete>
3737

3838
<pre class="status">Selected: {valueOutlined || ''}</pre>

0 commit comments

Comments
 (0)