Skip to content

Commit 3fa39f0

Browse files
authored
fix(ui): forward nativeSizeProp on input (#97750)
the underlying component takes `nativeSize` and maps it towards `size`, while also ignoring the actual `size` prop. However, this only works if `nativeSize` isn't filtered out by `shouldForwardProp`; additionally, the typeof 'string' check is unnecessary because according to the types, `prop` is `propName`, which is always a string
1 parent 8239205 commit 3fa39f0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

static/app/components/core/input/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const Input = styled(
3737

3838
...props
3939
}: InputProps) => <input {...props} ref={ref} size={nativeSize} />,
40-
{shouldForwardProp: prop => typeof prop === 'string' && isPropValid(prop)}
40+
{shouldForwardProp: prop => prop === 'nativeSize' || isPropValid(prop)}
4141
)`
4242
${inputStyles};
4343
`;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {render, screen} from 'sentry-test/reactTestingLibrary';
2+
3+
import {Input} from '.';
4+
5+
describe('Input', () => {
6+
it('maps nativeSize to size', () => {
7+
render(<Input size="md" nativeSize={5} />);
8+
9+
expect(screen.getByRole('textbox')).toBeInTheDocument();
10+
expect(screen.getByRole('textbox')).toHaveAttribute('size', '5');
11+
});
12+
});

0 commit comments

Comments
 (0)