Skip to content

Commit

Permalink
fix: properly forward the label to the textfield in autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
hperrin committed Dec 11, 2021
1 parent 735560d commit 8ffcab7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/autocomplete/src/Autocomplete.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
>
<slot>
<Textfield
{label}
bind:value={text}
{...prefixFilter($$restProps, 'textfield$')}
/>
Expand Down Expand Up @@ -114,6 +115,7 @@
export let getOptionLabel: (option: any) => string = (option: any) =>
option == null ? '' : `${option}`;
export let text = getOptionLabel(value);
export let label: string | undefined = undefined;
export let toggle = false;
export let combobox = false;
export let clearOnBlur = !combobox;
Expand Down
2 changes: 2 additions & 0 deletions packages/autocomplete/src/Autocomplete.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export declare class AutocompleteComponentDev extends Component {
| 'getOptionDisabled'
| 'getOptionLabel'
| 'text'
| 'label'
| 'toggle'
| 'combobox'
| 'clearOnBlur'
Expand All @@ -33,6 +34,7 @@ export declare class AutocompleteComponentDev extends Component {
} & {
[k in keyof ListComponentDev['$$prop_def'] as `list\$${k}`]?: ListComponentDev['$$prop_def'][k];
} & {
textfield$label?: never;
textfield$value?: never;
} & Component['$$prop_def'];
}
6 changes: 3 additions & 3 deletions packages/site/src/routes/demo/autocomplete/_Manual.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
bind:text={textStandard}
class="demo-autocomplete-width"
>
<Textfield bind:value={textStandard} />
<Textfield label="Fruit" bind:value={textStandard} />
</Autocomplete>

<pre class="status">Selected: {valueStandard || ''}</pre>
Expand All @@ -19,7 +19,7 @@
bind:text={textFilled}
class="demo-autocomplete-width"
>
<Textfield bind:value={textFilled} variant="filled" />
<Textfield label="Fruit" bind:value={textFilled} variant="filled" />
</Autocomplete>

<pre class="status">Selected: {valueFilled || ''}</pre>
Expand All @@ -32,7 +32,7 @@
bind:text={textOutlined}
class="demo-autocomplete-width"
>
<Textfield bind:value={textOutlined} variant="outlined" />
<Textfield label="Fruit" bind:value={textOutlined} variant="outlined" />
</Autocomplete>

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

0 comments on commit 8ffcab7

Please sign in to comment.