Skip to content

Commit fc01d03

Browse files
authored
input: do not export component with shouldForwardProps (#87198)
Emotion lies to us about props, and in this instance, will not forward any props, as the final props set seems to be an intersection of the [two](https://github.com/emotion-js/emotion/blob/main/packages/styled/src/utils.ts#L17) component prop sets. Since it only does this one level deep, it means we can wrap it
1 parent 6a63fd6 commit fc01d03

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export interface InputProps
8383
* To add leading/trailing items (e.g. a search icon on the left side), use
8484
* InputControl (components/inputControl) instead.
8585
*/
86-
export const Input = styled(
86+
87+
const StyledInput = styled(
8788
forwardRef<HTMLInputElement, InputProps>(
8889
(
8990
{
@@ -100,6 +101,15 @@ export const Input = styled(
100101
) => <input {...props} ref={ref} size={nativeSize} />
101102
),
102103
{shouldForwardProp: prop => typeof prop === 'string' && isPropValid(prop)}
104+
)``;
105+
106+
// This is a hack - emotion does not support overriding the shouldForwardProp
107+
// for styled components, but if we wrap it inside another component, we can
108+
// prevent it from doing that while still applying the styles.
109+
export const Input = styled(
110+
forwardRef<HTMLInputElement, InputProps>((props: InputProps, ref) => (
111+
<StyledInput {...props} ref={ref} />
112+
))
103113
)`
104114
${p => (p.theme.isChonk ? chonkInputStyles(p as any) : inputStyles(p))}
105115
`;

0 commit comments

Comments
 (0)