-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(scraps): make value and onChange required on compactSelect #103654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref(scraps): make value and onChange required on compactSelect #103654
Conversation
since we're switching towards fully controlled usages now that we don't have `defaultValue` anymore, it makes sense to require this on type-level. Most violations were in stories and tests, and in those cases where the value is actually irrelevant e.g. because we do a navigation, we can still explicitly pass value={undefined}
| <VisibleFocusButton | ||
| <Button | ||
| size="xs" | ||
| borderless | ||
| style={{background: filters.length > 0 ? theme.purple100 : 'transparent'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (isError) { | ||
| return ( | ||
| <Tooltip title={t('Error loading span categories')}> | ||
| <CompactSelect disabled options={[]} value={undefined} onChange={onChange} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this should probably just be a Button but 🤷♂️
| ); | ||
| } | ||
|
|
||
| const VisibleFocusButton = styled(Button)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
| <CompactSelect | ||
| grid | ||
| value={undefined} | ||
| onChange={jest.fn} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: CompactSelect test mocks created incorrectly without function call
All onChange mock assignments use jest.fn (without parentheses) instead of jest.fn() (with parentheses). This passes the jest factory function reference rather than a mock function instance, preventing call tracking. The correct pattern onChange={jest.fn()} is used in composite.spec.tsx and throughout the codebase.

since we're switching towards fully controlled usages now that we don't have
defaultValueanymore, it makes sense to require this on type-level. Most violations were in stories and tests, and in those cases where the value is actually irrelevant e.g. because we do a navigation, we can still explicitly pass value={undefined}