diff --git a/.changeset/strong-falcons-design.md b/.changeset/strong-falcons-design.md new file mode 100644 index 00000000000..672d642e1c0 --- /dev/null +++ b/.changeset/strong-falcons-design.md @@ -0,0 +1,5 @@ +--- +"@primer/react": patch +--- + +Update Select component to correctly pass className to TextInputWraper for styling purposes diff --git a/packages/react/src/Select/Select.dev.stories.module.css b/packages/react/src/Select/Select.dev.stories.module.css new file mode 100644 index 00000000000..c4f454d2aa5 --- /dev/null +++ b/packages/react/src/Select/Select.dev.stories.module.css @@ -0,0 +1,3 @@ +.DangerText { + color: var(--fgColor-danger); +} diff --git a/packages/react/src/Select/Select.dev.stories.tsx b/packages/react/src/Select/Select.dev.stories.tsx index 3217b59839e..6ff19d2baec 100644 --- a/packages/react/src/Select/Select.dev.stories.tsx +++ b/packages/react/src/Select/Select.dev.stories.tsx @@ -1,6 +1,7 @@ import type {Meta} from '@storybook/react-vite' -import {FormControl, Box} from '..' +import {FormControl} from '..' import Select from './Select' +import classes from './Select.dev.stories.module.css' export default { title: 'Components/Select/Dev', @@ -8,10 +9,10 @@ export default { } as Meta export const Default = () => ( - +
Default label - Choice one Choice two Choice three @@ -20,5 +21,5 @@ export const Default = () => ( Choice six - +
) diff --git a/packages/react/src/Select/Select.features.stories.module.css b/packages/react/src/Select/Select.features.stories.module.css new file mode 100644 index 00000000000..210cb5989e9 --- /dev/null +++ b/packages/react/src/Select/Select.features.stories.module.css @@ -0,0 +1,5 @@ +.CustomSelect { + border-radius: var(--borderRadius-large); + /* stylelint-disable-next-line primer/colors */ + border: var(--borderWidth-default) dashed #000; +} diff --git a/packages/react/src/Select/Select.features.stories.tsx b/packages/react/src/Select/Select.features.stories.tsx index ab78140a838..79e492b386b 100644 --- a/packages/react/src/Select/Select.features.stories.tsx +++ b/packages/react/src/Select/Select.features.stories.tsx @@ -1,12 +1,13 @@ -import {FormControl, Box, Heading} from '..' +import {FormControl, Heading} from '..' import Select from './Select' +import classes from './Select.features.stories.module.css' export default { title: 'Components/Select/Features', } export const WithOptionGroups = () => ( - +
Default label - +
) export const Disabled = () => ( - +
Default label - +
) export const WithCaption = () => ( - +
Default label This is a caption @@ -55,11 +56,11 @@ export const WithCaption = () => ( Choice six - +
) export const VisuallyHiddenLabel = () => ( - +
Primer form title @@ -75,11 +76,11 @@ export const VisuallyHiddenLabel = () => ( Label is visually hidden; the title describes the purpose visually - +
) export const Error = () => ( - +
Default label Something went wrong - +
) export const Success = () => ( - +
Default label Success - +
) export const Block = () => ( - +
Default label - +
) export const Small = () => ( - +
Default label - +
) export const Large = () => ( - +
Default label - +
) export const WithCustomStyling = () => ( - +
Default label - Choice one Choice two Choice three @@ -173,11 +174,11 @@ export const WithCustomStyling = () => ( Choice six - +
) export const WithPlaceholderOption = () => ( - +
Default label - +
) diff --git a/packages/react/src/Select/Select.stories.tsx b/packages/react/src/Select/Select.stories.tsx index d3c4523c71f..84e1f3170c8 100644 --- a/packages/react/src/Select/Select.stories.tsx +++ b/packages/react/src/Select/Select.stories.tsx @@ -1,5 +1,5 @@ import type {Meta} from '@storybook/react-vite' -import {FormControl, Box} from '..' +import {FormControl} from '..' import Select from './Select' import type {SelectProps} from './Select' import type {FormControlArgs} from '../utils/form-story-helpers' @@ -24,7 +24,7 @@ export const Playground = (args: FormControlArgs) => { const {parentArgs, labelArgs, captionArgs, validationArgs} = getFormControlArgsByChildComponent(args) return ( - +
@@ -64,5 +64,5 @@ export const Default = () => ( Choice six - +
) diff --git a/packages/react/src/Select/Select.test.tsx b/packages/react/src/Select/Select.test.tsx index 381d2d9d10a..1b1bab2d34f 100644 --- a/packages/react/src/Select/Select.test.tsx +++ b/packages/react/src/Select/Select.test.tsx @@ -8,7 +8,7 @@ describe('Select', () => { const Element = () => ( <> - Choice one Choice two Choice three @@ -18,7 +18,11 @@ describe('Select', () => { ) - expect(render().getAllByTestId('select-default')[0]).toHaveClass('test-class-name') + const {container} = render() + const select = container.querySelector('select') + const wrapper = container.querySelector('span.test-class-name') + expect(wrapper).toContainElement(select) + expect(wrapper).toHaveClass('test-class-name') }) it('renders a select input', () => { diff --git a/packages/react/src/Select/Select.tsx b/packages/react/src/Select/Select.tsx index ff0e1c7379e..7b79c7ef4f7 100644 --- a/packages/react/src/Select/Select.tsx +++ b/packages/react/src/Select/Select.tsx @@ -57,7 +57,7 @@ const Select = React.forwardRef( disabled={disabled} size={size} validationStatus={validationStatus} - className={classes.TextInputWrapper} + className={clsx(classes.TextInputWrapper, className)} sx={sx} >