Skip to content

Commit 31c1faf

Browse files
committed
refactor(headless select): change displayText prop to displayValue
1 parent 6acc4fb commit 31c1faf

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

.changeset/silent-yaks-crash.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The previous API did not allow for customization of list items. The new API intr
3232

3333
You can now put anything you'd like in your `<Select.Item />`, just like a normal li tag!
3434

35-
There is a new reactive signal called `bind:displayText` that can be used to read the value of the display text. There is a new docs example that shows this in action with item pills.
35+
There is a new reactive signal called `bind:displayValue` that can be used to read the value of the display text. There is a new docs example that shows this in action with item pills.
3636

3737
#### bind syntax
3838

apps/website/src/routes/docs/headless/select/examples/form.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type FormData = Record<string, FormDataEntryValue[]>;
77
export default component$(() => {
88
useStyles$(styles);
99
const users = ['Tim', 'Ryan', 'Jim', 'Jessie', 'Abby'];
10-
const displayText = useSignal<string[]>([]);
10+
const displayValue = useSignal<string[]>([]);
1111

1212
const submittedData = useSignal<FormData | null>(null);
1313
const formName = 'my-example-name!';
@@ -25,15 +25,15 @@ export default component$(() => {
2525
<form preventdefault:submit onSubmit$={handleSubmit$}>
2626
<Select.Root
2727
name={formName}
28-
bind:displayText={displayText}
28+
bind:displayValue={displayValue}
2929
multiple
3030
required
3131
class="select"
3232
>
3333
<Select.Label>Logged in users</Select.Label>
3434
<Select.HiddenNativeSelect />
3535
<Select.Trigger class="select-trigger">
36-
<Select.DisplayValue>{displayText.value.join(', ')}</Select.DisplayValue>
36+
<Select.DisplayValue>{displayValue.value.join(', ')}</Select.DisplayValue>
3737
</Select.Trigger>
3838
<Select.Popover class="select-popover">
3939
<Select.Listbox class="select-listbox">

apps/website/src/routes/docs/headless/select/examples/multiple-pill.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ export default component$(() => {
99
const selected = useSignal<string[]>([]);
1010

1111
return (
12-
<Select.Root multiple bind:displayText={display} bind:value={selected} class="select">
12+
<Select.Root
13+
multiple
14+
bind:displayValue={display}
15+
bind:value={selected}
16+
class="select"
17+
>
1318
<Select.Label>Logged in users</Select.Label>
1419
<Select.Trigger class="select-trigger">
1520
<Select.DisplayValue>

apps/website/src/routes/docs/headless/select/examples/multiple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default component$(() => {
88
const display = useSignal<string[]>([]);
99

1010
return (
11-
<Select.Root bind:displayText={display} multiple class="select">
11+
<Select.Root bind:displayValue={display} multiple class="select">
1212
<Select.Trigger class="select-trigger">
1313
<Select.DisplayValue>{display.value.join(', ')}</Select.DisplayValue>
1414
</Select.Trigger>

apps/website/src/routes/docs/headless/select/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ Sometimes we want to allow the user to select multiple pre-defined items at a ti
241241

242242
<Showcase name="multiple" />
243243

244-
If we want to configure the multiple display values, we can use the `bind:displayText` signal.
244+
If we want to configure the multiple display values, we can use the `bind:displayValue` signal.
245245

246246
Something to be aware of, is the `<Select.DisplayValue />` component will now display whatever you put inside of it.
247247

248-
> Under the hood, Qwik UI updates the `bind:displayText` signal with the latest display values.
248+
> Under the hood, Qwik UI updates the `bind:displayValue` signal with the latest display values.
249249
250-
Taking this a step further, one could combine the `bind:value` and `bind:displayText` props together to create a custom widget that displays the selected values in a list of pills.
250+
Taking this a step further, one could combine the `bind:value` and `bind:displayValue` props together to create a custom widget that displays the selected values in a list of pills.
251251

252252
<Showcase name="multiple-pill" />
253253

@@ -469,7 +469,7 @@ When in multi select mode, additional keyboard interactions are available.
469469
info: 'string',
470470
},
471471
{
472-
name: 'bind:displayText',
472+
name: 'bind:displayValue',
473473
type: 'signal',
474474
description: 'Controlled display value, manages the display items.',
475475
info: 'string',

packages/kit-headless/src/components/select/select-root.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type SelectProps<M extends boolean = boolean> = Omit<
6262
'bind:open'?: Signal<boolean>;
6363

6464
// eslint-disable-next-line @typescript-eslint/no-explicit-any
65-
'bind:displayText'?: Signal<TMultiple<M>>;
65+
'bind:displayValue'?: Signal<TMultiple<M>>;
6666

6767
/**
6868
* QRL handler that runs when a select value changes.
@@ -231,7 +231,7 @@ export const HSelectImpl = component$<SelectProps<boolean> & InternalSelectProps
231231

232232
useTask$(async function updateConsumerProps({ track }) {
233233
const bindValueSig = props['bind:value'];
234-
const bindDisplayTextSig = props['bind:displayText'];
234+
const bindDisplayTextSig = props['bind:displayValue'];
235235
track(() => selectedIndexSetSig.value);
236236

237237
const values = [];

0 commit comments

Comments
 (0)