Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7e74223
feat(TextInput): Remove width props from TextInput
hussam-i-am Nov 8, 2024
1958184
type fixes
hussam-i-am Nov 8, 2024
de2b18f
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 8, 2024
bbac544
Revert "Revert "feat(TextInput): Update TextInput to use data attribu…
hussam-i-am Nov 8, 2024
95c0827
Merge branch 'main' of https://github.com/primer/react into hussam-i-…
hussam-i-am Nov 8, 2024
a2fd736
lint fix
hussam-i-am Nov 8, 2024
5d36dd7
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 8, 2024
f64022b
remove unused imports
hussam-i-am Nov 8, 2024
66aa372
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 9, 2024
40ab2b3
fix type error and add test
hussam-i-am Nov 9, 2024
75a2a67
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 12, 2024
50e4f49
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 12, 2024
4c64a6c
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 12, 2024
c20c57a
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 12, 2024
ca14ee3
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 13, 2024
8086ba0
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 13, 2024
a97371d
Merge branch 'main' into hussam-i-am/remove-textinput-width-props
hussam-i-am Nov 13, 2024
abd6c29
Merge branch 'hussam-i-am/remove-textinput-width-props' into revert-5…
hussam-i-am Nov 13, 2024
7a9493b
Update to deprecate props
hussam-i-am Nov 13, 2024
9e4a9e5
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 13, 2024
a1c0433
Fix media styling
hussam-i-am Nov 13, 2024
8915312
revert back to get
hussam-i-am Nov 13, 2024
29464fd
revert more gets
hussam-i-am Nov 13, 2024
d7deba0
Properly mark props as deprecated
hussam-i-am Nov 13, 2024
ae9748b
Merge branch 'hussam-i-am/remove-textinput-width-props' of https://gi…
hussam-i-am Nov 13, 2024
4e51a6b
Merge branch 'main' of https://github.com/primer/react into revert-52…
hussam-i-am Nov 13, 2024
7b20e63
Merge branch 'main' into revert-5256-revert-5242-hussam-i-am/text-inp…
hussam-i-am Nov 14, 2024
6e9f2e7
Merge branch 'main' into revert-5256-revert-5242-hussam-i-am/text-inp…
hussam-i-am Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/real-fans-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Convert TextInput to use data attributes
4 changes: 3 additions & 1 deletion packages/react/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type {StyledWrapperProps} from '../internal/components/TextInputWrapper'
import TextInputWrapper from '../internal/components/TextInputWrapper'
import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent'
import {useFeatureFlag} from '../FeatureFlags'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'

import classes from './Select.module.css'

export type SelectProps = Omit<
Expand Down Expand Up @@ -167,7 +169,7 @@ const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
</TextInputWrapper>
)
},
)
) as PolymorphicForwardRefComponent<'select', SelectProps>

const Option: React.FC<React.PropsWithChildren<React.HTMLProps<HTMLOptionElement> & {value: string}>> = props => (
<option {...props} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Token from '../Token/Token'
import type {TokenSizeKeys} from '../Token/TokenBase'

import type {TextInputSizes} from '../internal/components/TextInputWrapper'
import TextInputWrapper, {textInputHorizPadding} from '../internal/components/TextInputWrapper'
import TextInputWrapper from '../internal/components/TextInputWrapper'
import UnstyledTextInput, {TEXT_INPUT_CSS_MODULES_FEATURE_FLAG} from '../internal/components/UnstyledTextInput'
import TextInputInnerVisualSlot from '../internal/components/TextInputInnerVisualSlot'
import {useFeatureFlag} from '../FeatureFlags'
Expand Down Expand Up @@ -271,8 +271,8 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
variant={variantProp} // deprecated. use `size` prop instead
onClick={focusInput}
sx={{
paddingLeft: textInputHorizPadding,
py: `calc(${textInputHorizPadding} / 2)`,
paddingLeft: '12px',
py: `calc(12px / 2)`,
...(block
? {
display: 'flex',
Expand Down
28 changes: 28 additions & 0 deletions packages/react/src/__tests__/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import {Select} from '..'
import {render} from '@testing-library/react'
import {FeatureFlags} from '../FeatureFlags'
import userEvent from '@testing-library/user-event'

describe('Select', () => {
it('should support `className` on the outermost element', () => {
Expand Down Expand Up @@ -155,4 +156,31 @@ describe('Select', () => {
expect(select).toHaveAttribute('disabled')
expect(select).toHaveAttribute('disabled')
})

it('trigger changes event when option selected', async () => {
const {getByLabelText} = render(
<>
<label htmlFor="default">Choice</label>
<Select
id="default"
onChange={e => {
expect(e.currentTarget.value).toBe('one')
}}
>
<Select.Option value="one">Choice one</Select.Option>
<Select.Option value="two">Choice two</Select.Option>
<Select.Option value="three">Choice three</Select.Option>
<Select.Option value="four">Choice four</Select.Option>
<Select.Option value="five">Choice five</Select.Option>
<Select.Option value="six">Choice six</Select.Option>
</Select>
</>,
)

const select = getByLabelText('Choice')

expect(select).toBeDefined()

await userEvent.selectOptions(select, 'one')
})
})
8 changes: 4 additions & 4 deletions packages/react/src/__tests__/Textarea.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ describe('Textarea', () => {
width: '100%',
display: 'flex',
}
const defaultStyles = renderStyles(<Textarea block />)
const blockStyles = renderStyles(<Textarea />)
const defaultStyles = renderStyles(<Textarea />)
const blockStyles = renderStyles(<Textarea block />)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated so that variable names match component props


expect(defaultStyles).toEqual(expect.objectContaining(expectedStyles))
expect(blockStyles).not.toEqual(expect.objectContaining(expectedStyles))
expect(defaultStyles).not.toEqual(expect.objectContaining(expectedStyles))
expect(blockStyles).toEqual(expect.objectContaining(expectedStyles))
})

it('renders default resize values correctly', () => {
Expand Down
Loading
Loading