Skip to content

Commit 019335b

Browse files
fix(ui): improve ReactSelect clear indicator positioning and sizing (#16440)
## Summary Refines ReactSelect clear indicator positioning and sizing to align with the design system. Uses token-based spacing and adds dynamic padding via `:has()` when clear indicator is present. Adds Select field test variants (disabled, read-only, hasMany) for visual testing.
1 parent 86dda3d commit 019335b

3 files changed

Lines changed: 107 additions & 5 deletions

File tree

packages/ui/src/elements/ReactSelect/ClearIndicator/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919

2020
.clear-indicator__icon {
21-
width: 1rem;
22-
height: 1rem;
21+
width: var(--spacer-3);
22+
height: var(--spacer-3);
2323
}
2424
}

packages/ui/src/elements/ReactSelect/index.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
flex-wrap: wrap;
2929
gap: var(--spacer-1);
3030

31+
&:has(.clear-indicator) {
32+
padding-inline-end: calc(var(--spacer-4) * 2);
33+
}
34+
3135
&:hover:not(:focus-within) {
3236
border-color: var(--border-default);
3337
}
@@ -59,11 +63,11 @@
5963

6064
.rs__indicators {
6165
position: absolute;
62-
right: 0;
63-
top: calc((var(--spacer-5) - 1rem - 2px) / 2);
66+
right: var(--spacer-1);
67+
top: 0;
68+
height: 100%;
6469
display: flex;
6570
align-items: center;
66-
padding-right: var(--spacer-2);
6771
}
6872

6973
.rs__input-container {

test/v4/collections/Select/index.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,104 @@ const SelectFields: CollectionConfig = {
3232
{ label: 'Archived', value: 'archived' },
3333
],
3434
},
35+
{
36+
name: 'statusDisabled',
37+
type: 'select',
38+
label: 'Status (Disabled)',
39+
defaultValue: 'draft',
40+
admin: {
41+
disabled: true,
42+
description: 'This field is disabled',
43+
},
44+
options: [
45+
{ label: 'Draft', value: 'draft' },
46+
{ label: 'Published', value: 'published' },
47+
{ label: 'Archived', value: 'archived' },
48+
],
49+
},
50+
{
51+
name: 'statusReadOnly',
52+
type: 'select',
53+
label: 'Status (Read Only)',
54+
defaultValue: 'published',
55+
admin: {
56+
readOnly: true,
57+
description: 'This field is read-only',
58+
},
59+
options: [
60+
{ label: 'Draft', value: 'draft' },
61+
{ label: 'Published', value: 'published' },
62+
{ label: 'Archived', value: 'archived' },
63+
],
64+
},
65+
{
66+
name: 'tags',
67+
type: 'select',
68+
label: 'Tags',
69+
hasMany: true,
70+
admin: {
71+
description: 'Select multiple tags',
72+
},
73+
options: [
74+
{ label: 'Technology', value: 'technology' },
75+
{ label: 'Design', value: 'design' },
76+
{ label: 'Marketing', value: 'marketing' },
77+
{ label: 'Engineering', value: 'engineering' },
78+
{ label: 'Product', value: 'product' },
79+
],
80+
},
81+
{
82+
name: 'tagsRequired',
83+
type: 'select',
84+
label: 'Tags (Required)',
85+
hasMany: true,
86+
required: true,
87+
admin: {
88+
description: 'At least one tag is required',
89+
},
90+
options: [
91+
{ label: 'Technology', value: 'technology' },
92+
{ label: 'Design', value: 'design' },
93+
{ label: 'Marketing', value: 'marketing' },
94+
{ label: 'Engineering', value: 'engineering' },
95+
{ label: 'Product', value: 'product' },
96+
],
97+
},
98+
{
99+
name: 'tagsReadOnly',
100+
type: 'select',
101+
label: 'Tags (Read Only)',
102+
hasMany: true,
103+
defaultValue: ['technology', 'design'],
104+
admin: {
105+
readOnly: true,
106+
description: 'These tags cannot be changed',
107+
},
108+
options: [
109+
{ label: 'Technology', value: 'technology' },
110+
{ label: 'Design', value: 'design' },
111+
{ label: 'Marketing', value: 'marketing' },
112+
{ label: 'Engineering', value: 'engineering' },
113+
{ label: 'Product', value: 'product' },
114+
],
115+
},
116+
{
117+
name: 'tagsWithManyValues',
118+
type: 'select',
119+
label: 'Tags (Many Values)',
120+
hasMany: true,
121+
defaultValue: ['technology', 'design', 'marketing', 'engineering', 'product'],
122+
admin: {
123+
description: 'Has many values to test wrapping',
124+
},
125+
options: [
126+
{ label: 'Technology', value: 'technology' },
127+
{ label: 'Design', value: 'design' },
128+
{ label: 'Marketing', value: 'marketing' },
129+
{ label: 'Engineering', value: 'engineering' },
130+
{ label: 'Product', value: 'product' },
131+
],
132+
},
35133
],
36134
}
37135

0 commit comments

Comments
 (0)