Skip to content

Commit e474edb

Browse files
authored
fix: badge text color inside listview (#8449)
* fix: badge text color inside listview * fix lint
1 parent 7e14ffa commit e474edb

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

packages/@react-spectrum/badge/src/Badge.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {classNames, SlotProvider, useDOMRef, useStyleProps} from '@react-spectrum/utils';
13+
import {classNames, ClearSlots, SlotProvider, useDOMRef, useStyleProps} from '@react-spectrum/utils';
1414
import {DOMRef} from '@react-types/shared';
1515
import {filterDOMProps} from '@react-aria/utils';
1616
import React, {forwardRef} from 'react';
@@ -47,23 +47,25 @@ export const Badge = forwardRef(function Badge(props: SpectrumBadgeProps, ref: D
4747
styleProps.className
4848
)}
4949
ref={domRef}>
50-
<SlotProvider
51-
slots={{
52-
icon: {
53-
size: 'S',
54-
UNSAFE_className: classNames(styles, 'spectrum-Badge-icon')
55-
},
56-
text: {
57-
UNSAFE_className: classNames(styles, 'spectrum-Badge-label')
58-
}
59-
}}>
50+
<ClearSlots>
51+
<SlotProvider
52+
slots={{
53+
icon: {
54+
size: 'S',
55+
UNSAFE_className: classNames(styles, 'spectrum-Badge-icon')
56+
},
57+
text: {
58+
UNSAFE_className: classNames(styles, 'spectrum-Badge-label')
59+
}
60+
}}>
6061

61-
{
62-
typeof children === 'string' || isTextOnly
63-
? <Text>{children}</Text>
64-
: children
65-
}
66-
</SlotProvider>
62+
{
63+
typeof children === 'string' || isTextOnly
64+
? <Text>{children}</Text>
65+
: children
66+
}
67+
</SlotProvider>
68+
</ClearSlots>
6769
</span>
6870
);
6971
});

packages/@react-spectrum/list/stories/ListView.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {action} from '@storybook/addon-actions';
22
import {ActionBar, ActionBarContainer} from '@react-spectrum/actionbar';
33
import {ActionButton, Button} from '@react-spectrum/button';
44
import {ActionGroup} from '@react-spectrum/actiongroup';
5+
import {Badge} from '@react-spectrum/badge';
56
import {Content} from '@react-spectrum/view';
67
import Copy from '@spectrum-icons/workflow/Copy';
78
import Delete from '@spectrum-icons/workflow/Delete';
@@ -144,7 +145,7 @@ export type ListViewStory = StoryObj<typeof ListView>;
144145
export const Default: ListViewStory = {
145146
render: (args) => (
146147
<ListView disabledKeys={['3']} width="250px" aria-label="default ListView" {...args}>
147-
<Item key="1" textValue="Adobe Photoshop">Adobe Photoshop</Item>
148+
<Item key="1" textValue="Adobe Photoshop"><Badge variant="neutral">2</Badge>Adobe Photoshop</Item>
148149
<Item key="2" textValue="Adobe Illustrator">Adobe Illustrator</Item>
149150
<Item key="3" textValue="Adobe XD">Adobe XD</Item>
150151
</ListView>

0 commit comments

Comments
 (0)