Skip to content

Commit 61b14f4

Browse files
committed
Fix SelectNext styles when used inside an InputGroup
1 parent 2fa74d9 commit 61b14f4

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

src/components/input/SelectNext.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useSyncedRef } from '../../hooks/use-synced-ref';
1717
import type { PresentationalProps } from '../../types';
1818
import { MenuCollapseIcon, MenuExpandIcon } from '../icons';
1919
import Button from './Button';
20+
import { inputGroupStyles } from './InputGroup';
2021
import SelectContext from './SelectContext';
2122

2223
export type SelectOptionStatus = {
@@ -185,12 +186,15 @@ function SelectMain<T>({
185186
}, [buttonRef, listboxOpen]);
186187

187188
return (
188-
<div className="relative" ref={wrapperRef}>
189+
<div
190+
className={classnames('relative w-full border rounded', inputGroupStyles)}
191+
ref={wrapperRef}
192+
>
189193
<Button
190194
id={buttonId ?? defaultButtonId}
191195
variant="custom"
192196
classes={classnames(
193-
'w-full flex border rounded',
197+
'w-full flex',
194198
'bg-grey-0 disabled:bg-grey-1 disabled:text-grey-6',
195199
classes,
196200
)}

src/pattern-library/components/patterns/prototype/SelectNextPage.tsx

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,40 +92,38 @@ function InputGroupSelectExample() {
9292
onClick={previous}
9393
disabled={selectedIndex <= 0}
9494
/>
95-
<div className="w-full">
96-
<SelectNext
97-
value={selected}
98-
onChange={setSelected}
99-
buttonContent={
100-
selected ? (
95+
<SelectNext
96+
value={selected}
97+
onChange={setSelected}
98+
buttonContent={
99+
selected ? (
100+
<>
101+
{selected.name}
102+
<div className="rounded px-2 bg-grey-7 text-white">
103+
{selected.id}
104+
</div>
105+
</>
106+
) : (
107+
<>Select one...</>
108+
)
109+
}
110+
>
111+
{defaultItems.map(item => (
112+
<SelectNext.Option value={item} key={item.id}>
113+
{() => (
101114
<>
102-
{selected.name}
103-
<div className="rounded px-2 bg-grey-7 text-white">
104-
{selected.id}
115+
{item.name}
116+
<div className="grow" />
117+
<div
118+
className={classnames('rounded px-2 text-white bg-grey-7')}
119+
>
120+
{item.id}
105121
</div>
106122
</>
107-
) : (
108-
<>Select one...</>
109-
)
110-
}
111-
>
112-
{defaultItems.map(item => (
113-
<SelectNext.Option value={item} key={item.id}>
114-
{() => (
115-
<>
116-
{item.name}
117-
<div className="grow" />
118-
<div
119-
className={classnames('rounded px-2 text-white bg-grey-7')}
120-
>
121-
{item.id}
122-
</div>
123-
</>
124-
)}
125-
</SelectNext.Option>
126-
))}
127-
</SelectNext>
128-
</div>
123+
)}
124+
</SelectNext.Option>
125+
))}
126+
</SelectNext>
129127
<IconButton
130128
icon={ArrowRightIcon}
131129
title="Next student"

0 commit comments

Comments
 (0)