From 35767cf1c177eed9e6dd868b89aa6400f8a01f3a Mon Sep 17 00:00:00 2001 From: llastflowers Date: Wed, 6 Aug 2025 12:47:38 -0700 Subject: [PATCH 1/9] Update Select.features.stories.tsx to no longer use styled-components --- .../Select/Select.features.stories.module.css | 5 ++ .../src/Select/Select.features.stories.tsx | 49 ++++++++++--------- packages/react/src/Select/Select.tsx | 4 +- 3 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 packages/react/src/Select/Select.features.stories.module.css 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..37ca2151385 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.tsx b/packages/react/src/Select/Select.tsx index ff0e1c7379e..4b64d2685a0 100644 --- a/packages/react/src/Select/Select.tsx +++ b/packages/react/src/Select/Select.tsx @@ -11,6 +11,7 @@ export type SelectProps = Omit< 'multiple' | 'hasLeadingVisual' | 'hasTrailingVisual' | 'as' > & { placeholder?: string + wrapperClassName?: string } const ArrowIndicatorSVG: React.FC> = ({className}) => { @@ -46,6 +47,7 @@ const Select = React.forwardRef( required, validationStatus, sx, + wrapperClassName, ...rest }: SelectProps, ref, @@ -57,7 +59,7 @@ const Select = React.forwardRef( disabled={disabled} size={size} validationStatus={validationStatus} - className={classes.TextInputWrapper} + className={clsx(classes.TextInputWrapper, wrapperClassName)} sx={sx} > @@ -40,7 +41,7 @@ export const Playground = (args: FormControlArgs) => { )} -
+ ) } Playground.args = { @@ -52,7 +53,7 @@ Playground.argTypes = { } export const Default = () => ( - +
Default label - +
) From 2651e2554b32896fb26ad2cd637e4452a6092149 Mon Sep 17 00:00:00 2001 From: llastflowers Date: Wed, 6 Aug 2025 13:03:19 -0700 Subject: [PATCH 3/9] remove unused import --- packages/react/src/Select/Select.stories.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react/src/Select/Select.stories.tsx b/packages/react/src/Select/Select.stories.tsx index a3a4cbd7999..84e1f3170c8 100644 --- a/packages/react/src/Select/Select.stories.tsx +++ b/packages/react/src/Select/Select.stories.tsx @@ -9,7 +9,6 @@ import { getFormControlArgsByChildComponent, inputWrapperArgTypes, } from '../utils/form-story-helpers' -import classes from './Select.stories.module.css' export default { title: 'Components/Select', From c1b5d7354cf36a463decb968e5f9b6d1aeb5c5a8 Mon Sep 17 00:00:00 2001 From: llastflowers Date: Wed, 6 Aug 2025 13:39:57 -0700 Subject: [PATCH 4/9] Update Select.dev.stories.tsx to no longer use styled-components --- packages/react/src/Select/Select.dev.stories.module.css | 3 +++ packages/react/src/Select/Select.dev.stories.tsx | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 packages/react/src/Select/Select.dev.stories.module.css 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..3c2b2f763ab 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 - +
) From 48aa490b3e4614167fd8467b1fa93e746f284eda Mon Sep 17 00:00:00 2001 From: llastflowers Date: Thu, 7 Aug 2025 10:42:31 -0700 Subject: [PATCH 5/9] update to move className prop from Select to TextInputWrapper for direct Select styling --- packages/react/src/Select/Select.dev.stories.tsx | 2 +- packages/react/src/Select/Select.features.stories.tsx | 2 +- packages/react/src/Select/Select.tsx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react/src/Select/Select.dev.stories.tsx b/packages/react/src/Select/Select.dev.stories.tsx index 3c2b2f763ab..6ff19d2baec 100644 --- a/packages/react/src/Select/Select.dev.stories.tsx +++ b/packages/react/src/Select/Select.dev.stories.tsx @@ -12,7 +12,7 @@ export const Default = () => (
Default label - Choice one Choice two Choice three diff --git a/packages/react/src/Select/Select.features.stories.tsx b/packages/react/src/Select/Select.features.stories.tsx index 37ca2151385..79e492b386b 100644 --- a/packages/react/src/Select/Select.features.stories.tsx +++ b/packages/react/src/Select/Select.features.stories.tsx @@ -165,7 +165,7 @@ export const WithCustomStyling = () => ( Default label - Choice one Choice two Choice three diff --git a/packages/react/src/Select/Select.tsx b/packages/react/src/Select/Select.tsx index 4b64d2685a0..12b19a327f2 100644 --- a/packages/react/src/Select/Select.tsx +++ b/packages/react/src/Select/Select.tsx @@ -59,7 +59,7 @@ const Select = React.forwardRef( disabled={disabled} size={size} validationStatus={validationStatus} - className={clsx(classes.TextInputWrapper, wrapperClassName)} + className={clsx(classes.TextInputWrapper, className)} sx={sx} > Date: Thu, 7 Aug 2025 12:11:51 -0700 Subject: [PATCH 9/9] remove testid prop and instead update test to check for the className on the outer span wrapper of the select, which is TextInputWrapper --- packages/react/src/Select/Select.test.tsx | 8 ++++++-- packages/react/src/Select/Select.tsx | 3 --- 2 files changed, 6 insertions(+), 5 deletions(-) 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 88a9a00d773..7b79c7ef4f7 100644 --- a/packages/react/src/Select/Select.tsx +++ b/packages/react/src/Select/Select.tsx @@ -11,7 +11,6 @@ export type SelectProps = Omit< 'multiple' | 'hasLeadingVisual' | 'hasTrailingVisual' | 'as' > & { placeholder?: string - 'data-testid'?: string } const ArrowIndicatorSVG: React.FC> = ({className}) => { @@ -47,7 +46,6 @@ const Select = React.forwardRef( required, validationStatus, sx, - 'data-testid': dataTestId, ...rest }: SelectProps, ref, @@ -61,7 +59,6 @@ const Select = React.forwardRef( validationStatus={validationStatus} className={clsx(classes.TextInputWrapper, className)} sx={sx} - data-testid={dataTestId} >