Skip to content

Commit 2bf4997

Browse files
refactor(select): added research
1 parent 15acaae commit 2bf4997

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { component$, useSignal } from '@builder.io/qwik';
2+
3+
export default component$(() => {
4+
const usersSig = useSignal<string[]>(['Tim', 'Ryan', 'Jim', 'Jessie', 'Abby']);
5+
6+
return (
7+
<select multiple size={3}>
8+
{usersSig.value.map((user) => (
9+
<option key={user}>{user}</option>
10+
))}
11+
</select>
12+
);
13+
});

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { statusByComponent } from '~/_state/component-statuses';
88

99
# Select
1010

11-
This element is used to create a drop-down list, it's often used in a form, to collect user input.
11+
Reveals a list of options to choose from, often triggered by a button.
1212

1313
## Hero
1414

@@ -84,6 +84,10 @@ This element is used to create a drop-down list, it's often used in a form, to c
8484
<Showcase name="loop" />
8585
</div>
8686

87+
<div data-testid="select-normal-test">
88+
<Showcase name="normal-select" />
89+
</div>
90+
8791
## Building blocks
8892

8993
<CodeSnippet name="building-blocks" />

apps/website/src/routes/docs/headless/select/select.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ test.describe('Mouse Behavior', () => {
106106
await options[7].click();
107107
expect(await getValue()).toEqual(await options[7].textContent());
108108
});
109+
110+
// if we want to add focusing the trigger on blur
111+
// test(`GIVEN a basic select
112+
// WHEN the listbox is open and the blur event is triggered
113+
// THEN focus should go back to the trigger`, async ({ page }) => {
114+
// const { getTrigger, openListbox } = await setup(page, 'select-hero-test');
115+
116+
// await openListbox('click');
117+
// await getTrigger().blur();
118+
// await expect(getTrigger()).toBeFocused();
119+
// });
109120
});
110121

111122
test.describe('Keyboard Behavior', () => {

packages/kit-headless/src/components/select/notes.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,36 @@ Inspiration:
55
- Radix UI
66
- Kobalte UI
77
- Melt UI
8+
- Ariakit
89

910
What do they all have in common? How do people use them? What are the most important features?
1011

1112
# Select Research
1213

14+
## Native Select Pain Points:
15+
16+
- Styling is a pain
17+
- Multiselect is not intuitive (especially for non-technical users) It requires ctrl or command keys to select multiple options
18+
- Limited typehead support
19+
- Inconsistent behavior across browsers and devices (including styling)
20+
re: https://www.custarddoughnuts.co.uk/article/2019/11/3/it-shouldnt-still-be-difficult-to-style-a-select-element
21+
22+
## UX Pain Points:
23+
24+
- Because it's compact, visually indicates it's unimportant
25+
- More difficult to use than a text input
26+
- Users sometimes do not see them
27+
- They look "filled" (the placeholder) even though you need a user input
28+
- Lack of context (confusion on what the purpose of the select is)
29+
- Options are not always visible at once (especially compared to radio buttons)
30+
31+
## When should we use a select?
32+
33+
- Limited space
34+
- Input is nonessential (ex: list sorting)
35+
36+
resource: https://joshwayne.com/posts/the-problem-with-dropdowns/
37+
1338
## Anatomy:
1439

1540
<Select>
@@ -108,3 +133,7 @@ What do they all have in common? How do people use them? What are the most impor
108133

109134
key: Escape
110135
description: Pressing Escape closes the select menu. The trigger is then focused.
136+
137+
Downsides of our inline component approach:
138+
139+
Much like the native select's drawback, we have a "fixed structure", an expected DOM hierarchy that limits customization. It also throws an error if that hierarchy is not followed.

0 commit comments

Comments
 (0)