Skip to content

Commit 8ae12a5

Browse files
authored
Merge pull request #194 from UgnisSoftware/UGN-371-3
UGN-371 bugfix - fix select component alignment issues
2 parents 2429f82 + 398fb81 commit 8ae12a5

File tree

3 files changed

+33
-72
lines changed

3 files changed

+33
-72
lines changed

src/components/Selects/MatchColumnSelect.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const MatchColumnSelect = ({ onChange, value, options, placeholder, name
1717
<Select<SelectOption, false>
1818
value={value || null}
1919
colorScheme="gray"
20+
useBasicStyles
2021
onChange={onChange}
2122
placeholder={placeholder}
2223
options={options}

src/components/Selects/TableSelect.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const TableSelect = ({ onChange, value, options }: Props) => {
1717
return (
1818
<Select<SelectOption, false>
1919
autoFocus
20+
useBasicStyles
2021
size="sm"
2122
value={value}
2223
onChange={onChange}

src/theme.ts

Lines changed: 31 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -217,44 +217,16 @@ export const themeOverrides = {
217217
},
218218
},
219219
select: {
220-
dropdownIndicator: (provided) => ({
221-
...provided,
222-
background: "none",
223-
border: "none",
224-
p: 0,
225-
w: "40px",
226-
color: "textColor",
227-
}),
228220
control: (provided) => ({
229221
...provided,
230-
background: "none",
231-
borderRadius: "6px",
232-
p: 0,
233-
// _focus, _hover, _invalid, _readonly pseudoselectors can be used here for alternate border colors
234-
_focus: undefined,
235-
}),
236-
input: (provided) => ({
237-
...provided,
238-
background: "none",
239-
border: "none",
240-
p: 0,
241-
}),
242-
indicatorSeparator: (provided) => ({
243-
...provided,
244-
opacity: 0,
245-
}),
246-
singleValue: (provided) => ({
247-
...provided,
248-
ml: 0,
249-
mr: 0,
250-
}),
251-
placeholder: (provided) => ({
252-
...provided,
253-
color: "inactiveColor",
254-
}),
255-
valueContainer: (provided) => ({
256-
...provided,
257-
color: "textColor",
222+
borderColor: "border",
223+
_hover: {
224+
borderColor: "border",
225+
},
226+
["&[data-focus-visible]"]: {
227+
borderColor: "border",
228+
boxShadow: "none",
229+
},
258230
}),
259231
menu: (provided) => ({
260232
...provided,
@@ -264,12 +236,12 @@ export const themeOverrides = {
264236
menuList: (provided) => ({
265237
...provided,
266238
bg: "background",
267-
minW: "initial",
239+
borderColor: "border",
268240
}),
269241
option: (provided, state) => ({
270242
...provided,
271243
color: "textColor",
272-
bg: state.isSelected || state.isFocused ? "highlight" : provided.bg,
244+
bg: state.isSelected || state.isFocused ? "highlight" : "background",
273245
overflow: "hidden",
274246
textOverflow: "ellipsis",
275247
display: "block",
@@ -278,6 +250,14 @@ export const themeOverrides = {
278250
bg: "highlight",
279251
},
280252
}),
253+
placeholder: (provided) => ({
254+
...provided,
255+
color: "inactiveColor",
256+
}),
257+
noOptionsMessage: (provided) => ({
258+
...provided,
259+
color: "inactiveColor",
260+
}),
281261
} as ChakraStylesConfig<SelectOption>,
282262
},
283263
},
@@ -288,58 +268,37 @@ export const themeOverrides = {
288268
fontSize: "3xl",
289269
},
290270
select: {
291-
dropdownIndicator: (provided) => ({
292-
...provided,
293-
background: "none",
294-
border: "none",
295-
p: 0,
296-
w: "40px",
297-
}),
298-
control: (provided) => ({
299-
...provided,
300-
background: "none",
301-
border: "none",
302-
p: 0,
303-
_focus: undefined,
304-
}),
305-
input: (provided) => ({
306-
...provided,
307-
background: "none",
308-
border: "none",
309-
p: 0,
310-
}),
311-
indicatorSeparator: (provided) => ({
312-
...provided,
313-
opacity: 0,
314-
}),
315-
singleValue: (provided) => ({
316-
...provided,
317-
marginInlineStart: 0,
318-
}),
319271
valueContainer: (provided) => ({
320272
...provided,
321-
p: 0,
322-
paddingInlineStart: 2,
323-
color: "gray.400",
273+
py: 0,
274+
px: 1.5,
324275
}),
276+
inputContainer: (provided) => ({ ...provided, py: 0 }),
277+
control: (provided) => ({ ...provided, border: "none" }),
278+
input: (provided) => ({ ...provided, color: "textColor" }),
325279
menu: (provided) => ({
326280
...provided,
327281
p: 0,
328282
mt: 0,
329283
}),
330284
menuList: (provided) => ({
331285
...provided,
332-
minW: "initial",
286+
bg: "background",
287+
borderColor: "border",
333288
}),
334289
option: (provided, state) => ({
335290
...provided,
336-
color: state.isSelected ? "gray.900" : provided.color,
337-
bg: state.isSelected || state.isFocused ? "secondaryBackground" : provided.bg,
291+
color: "textColor",
292+
bg: state.isSelected || state.isFocused ? "highlight" : "background",
338293
overflow: "hidden",
339294
textOverflow: "ellipsis",
340295
display: "block",
341296
whiteSpace: "nowrap",
342297
}),
298+
noOptionsMessage: (provided) => ({
299+
...provided,
300+
color: "inactiveColor",
301+
}),
343302
} as ChakraStylesConfig<SelectOption>,
344303
},
345304
},

0 commit comments

Comments
 (0)