diff --git a/static/app/components/core/compactSelect/compactSelect.stories.tsx b/static/app/components/core/compactSelect/compactSelect.stories.tsx index 35c4090e7bfd72..da96558a5ccae0 100644 --- a/static/app/components/core/compactSelect/compactSelect.stories.tsx +++ b/static/app/components/core/compactSelect/compactSelect.stories.tsx @@ -561,6 +561,8 @@ const arrayToOptions = (array: string[]) => array.map(item => ({ value: item, label: item, + details: 'Details', + leadingItems: , })); const COUNTRY_NAMES = Object.keys(countryNameToCode).sort(); diff --git a/static/app/components/core/compactSelect/gridList/option.tsx b/static/app/components/core/compactSelect/gridList/option.tsx index 17b6cbeca3c25a..959d51597a6468 100644 --- a/static/app/components/core/compactSelect/gridList/option.tsx +++ b/static/app/components/core/compactSelect/gridList/option.tsx @@ -8,7 +8,7 @@ import type {ListState} from '@react-stately/list'; import type {Node} from '@react-types/shared'; import {Checkbox} from 'sentry/components/core/checkbox'; -import {CheckWrap} from 'sentry/components/core/compactSelect/styles'; +import {LeadWrap} from 'sentry/components/core/compactSelect/styles'; import {InnerWrap, MenuListItem} from 'sentry/components/core/menuListItem'; import {IconCheckmark} from 'sentry/icons'; import {space} from 'sentry/styles/space'; @@ -84,34 +84,35 @@ export function GridListOption({node, listState, size}: GridListOptionProps) { const leadingItemsMemo = useMemo(() => { const checkboxSize = size === 'xs' ? 'xs' : 'sm'; - if (hideCheck && !leadingItems) { - return null; + const leading = + typeof leadingItems === 'function' + ? leadingItems({disabled: isDisabled, isFocused, isSelected}) + : leadingItems; + + if (hideCheck) { + return leading; } return ( - {!hideCheck && ( - - {multiple ? ( - - ) : ( - isSelected && - )} - - )} - {typeof leadingItems === 'function' - ? leadingItems({disabled: isDisabled, isFocused, isSelected}) - : leadingItems} + + {multiple ? ( + + ) : ( + isSelected && + )} + + {leading ? {leading} : null} ); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [multiple, isSelected, isDisabled, size, leadingItems, hideCheck]); + }, [multiple, isSelected, isDisabled, isFocused, size, leadingItems, hideCheck]); return ( { const checkboxSize = size === 'xs' ? 'xs' : 'sm'; - if (hideCheck && !leadingItems) { - return null; + const leading = + typeof leadingItems === 'function' + ? leadingItems({disabled: isDisabled, isFocused, isSelected}) + : leadingItems; + + if (hideCheck) { + return leading; } return ( - {!hideCheck && ( - - )} - {leadingItems} + + {leading ? : null} ); - }, [multiple, isSelected, isDisabled, size, leadingItems, hideCheck]); + }, [size, leadingItems, isDisabled, isFocused, isSelected, hideCheck, multiple]); return ( ` - display: flex; - justify-content: center; - align-items: center; - min-width: 1em; - height: 1.4em; - padding-bottom: 1px; - pointer-events: none; -`; +export function LeadWrap(props: FlexProps) { + return ( + + ); +} export const EmptyMessage = styled('p')` text-align: center; diff --git a/static/app/components/events/breadcrumbs/utils.tsx b/static/app/components/events/breadcrumbs/utils.tsx index 81b89cd796a16b..5104acfad2d53d 100644 --- a/static/app/components/events/breadcrumbs/utils.tsx +++ b/static/app/components/events/breadcrumbs/utils.tsx @@ -58,6 +58,7 @@ export const BREADCRUMB_TIME_DISPLAY_LOCALSTORAGE_KEY = 'event-breadcrumb-time-d const Color = styled('span')<{ colorConfig: NonNullable; }>` + display: flex; color: ${p => p.colorConfig.icon}; `; diff --git a/static/app/components/organizations/hybridFilter.spec.tsx b/static/app/components/organizations/hybridFilter.spec.tsx index f7f5253ee7ce04..fa13728dddd9a2 100644 --- a/static/app/components/organizations/hybridFilter.spec.tsx +++ b/static/app/components/organizations/hybridFilter.spec.tsx @@ -1,3 +1,5 @@ +import {useState} from 'react'; + import { fireEvent, render, @@ -57,9 +59,23 @@ describe('ProjectPageFilter', () => { it('handles multiple selection', async () => { const onChange = jest.fn(); - const {rerender} = render( - - ); + function ControlledHybridFilter() { + const [value, setValue] = useState([]); + + return ( + { + onChange(newValue); + setValue(newValue); + }} + /> + ); + } + + render(); // Clicking on the checkboxes in Option One & Option Two _adds_ the options to the // current selection state (multiple selection mode) @@ -73,15 +89,6 @@ describe('ProjectPageFilter', () => { await userEvent.click(screen.getByRole('button', {name: 'Apply'})); expect(onChange).toHaveBeenCalledWith(expect.arrayContaining(['one', 'two'])); - // HybridFilter is controlled-only, so we need to rerender it with new value - rerender( - - ); await userEvent.click(screen.getByRole('button', {expanded: false})); // Ctrl-clicking on Option One & Option Two _removes_ them to the current selection diff --git a/static/app/views/dashboards/editAccessSelector.tsx b/static/app/views/dashboards/editAccessSelector.tsx index 1e084c80283972..3a4fc3367b9f85 100644 --- a/static/app/views/dashboards/editAccessSelector.tsx +++ b/static/app/views/dashboards/editAccessSelector.tsx @@ -14,7 +14,6 @@ import {Tag} from 'sentry/components/core/badge/tag'; import {Button} from 'sentry/components/core/button'; import {ButtonBar} from 'sentry/components/core/button/buttonBar'; import {CompactSelect} from 'sentry/components/core/compactSelect'; -import {CheckWrap} from 'sentry/components/core/compactSelect/styles'; import {InnerWrap, LeadingItems} from 'sentry/components/core/menuListItem'; import {Tooltip} from 'sentry/components/core/tooltip'; import UserBadge from 'sentry/components/idBadge/userBadge'; @@ -412,10 +411,6 @@ const StyledCompactSelect = styled(CompactSelect)` ${LeadingItems} { margin-top: 0; } - - ${CheckWrap} { - padding-bottom: 0; - } `; const StyledDisplayName = styled('div')`