Skip to content

Commit 8ef01d3

Browse files
authored
fix: segmented control follow-up (#7057)
* fix hcm * fix truncating
1 parent 6dbcdc7 commit 8ef01d3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

packages/@react-spectrum/s2/src/SegmentedControl.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const controlItem = style({
7979
flexBasis: 0,
8080
flexGrow: 1,
8181
flexShrink: 0,
82+
minWidth: 0,
8283
justifyContent: 'center',
8384
whiteSpace: 'nowrap',
8485
disableTapHighlight: true,
@@ -90,7 +91,13 @@ const controlItem = style({
9091

9192
const slider = style({
9293
...focusRing(),
93-
backgroundColor: 'gray-25',
94+
backgroundColor: {
95+
default: 'gray-25',
96+
forcedColors: {
97+
default: 'Highlight',
98+
isDisabled: 'GrayText'
99+
}
100+
},
94101
left: 0,
95102
width: 'full',
96103
height: 'full',
@@ -100,7 +107,11 @@ const slider = style({
100107
borderWidth: 2,
101108
borderColor: {
102109
default: 'gray-900',
103-
isDisabled: 'disabled'
110+
isDisabled: 'disabled',
111+
forcedColors: {
112+
default: 'Highlight',
113+
isDisabled: 'GrayText'
114+
}
104115
},
105116
borderRadius: 'lg'
106117
});
@@ -236,7 +247,7 @@ function SegmentedControlItem(props: SegmentedControlItemProps, ref: FocusableRe
236247
[RACTextContext, {slots: {[DEFAULT_SLOT]: {}}}],
237248
[TextContext, {styles: style({order: 1, truncate: true})}]
238249
]}>
239-
<div ref={divRef} style={pressScale(divRef)({isPressed})} className={style({zIndex: 1, display: 'flex', gap: 'text-to-visual', transition: 'default', alignItems: 'center'})}>
250+
<div ref={divRef} style={pressScale(divRef)({isPressed})} className={style({zIndex: 1, display: 'flex', gap: 'text-to-visual', transition: 'default', alignItems: 'center', minWidth: 0})}>
240251
{typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}
241252
</div>
242253
</Provider>

packages/@react-spectrum/s2/stories/SegmentedControl.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const meta: Meta<typeof SegmentedControl> = {
3232
export default meta;
3333

3434
export const Example = (args: any) => (
35-
<SegmentedControl {...args}>
35+
<SegmentedControl {...args} styles={style({width: '[250px]'})}>
3636
<SegmentedControlItem value="day">Day</SegmentedControlItem>
3737
<SegmentedControlItem value="week">Week</SegmentedControlItem>
3838
<SegmentedControlItem value="month">Month</SegmentedControlItem>
@@ -45,7 +45,7 @@ Example.args = {
4545
};
4646

4747
export const WithIcons = (args: any) => (
48-
<SegmentedControl {...args}>
48+
<SegmentedControl {...args} styles={style({width: '[400px]'})}>
4949
<SegmentedControlItem value="unordered"><ListBulleted /><Text>Unordered</Text></SegmentedControlItem>
5050
<SegmentedControlItem value="ordered"><ListNumbered /><Text>Ordered</Text></SegmentedControlItem>
5151
<SegmentedControlItem value="task list"><ListMultiSelect /><Text>Task List</Text></SegmentedControlItem>

0 commit comments

Comments
 (0)