Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion static/app/views/issueList/actions/sortOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import type {DropdownButtonProps} from 'sentry/components/dropdownButton';
import {IconSort} from 'sentry/icons/iconSort';
import {t} from 'sentry/locale';
import {useOrganization} from 'sentry/utils/useOrganization';
import {useParams} from 'sentry/utils/useParams';
import {
FOR_REVIEW_QUERIES,
getSortLabel,
getStoredIssueSort,
IssueSortOptions,
} from 'sentry/views/issueList/utils';

Expand Down Expand Up @@ -56,9 +58,13 @@ export function IssueListSortOptions({
showIcon = true,
}: Props) {
const organization = useOrganization();
const {viewId} = useParams<{viewId?: string}>();
const hasRecommendedSortDefault = organization.features.includes(
'issue-stream-recommended-sort-default'
);
// The trigger badge announces the Recommended default. A stored sort means
// the user has already made an explicit choice, so stop announcing.
const hasChosenSort = getStoredIssueSort(organization.slug) !== null;
const hasProgressSort =
organization.features.includes('issue-stream-progress-sort') ||
sort === IssueSortOptions.PROGRESS;
Expand Down Expand Up @@ -108,7 +114,10 @@ export function IssueListSortOptions({
size={triggerSize}
icon={showIcon && <IconSort />}
>
{hasRecommendedSortDefault && sortKey === IssueSortOptions.RECOMMENDED ? (
{hasRecommendedSortDefault &&
!hasChosenSort &&
!viewId &&
sortKey === IssueSortOptions.RECOMMENDED ? (
<Flex as="span" gap="sm" align="center">
{triggerProps.children}
<FeatureBadge
Expand Down
21 changes: 21 additions & 0 deletions static/app/views/issueList/overview.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,27 @@ describe('IssueList', () => {
const recommendedOption = screen.getByRole('option', {name: /Recommended/});
expect(within(recommendedOption).getByLabelText('new')).toBeInTheDocument();
});

it('hides the trigger badge once the user has chosen a sort', async () => {
const featureOrg = OrganizationFixture({
...organization,
features: ['issue-stream-recommended-sort-default'],
});
// An explicitly chosen sort (even Recommended itself) means the user has
// seen the dropdown, so the announcement badge no longer shows
setStoredIssueSort(featureOrg.slug, IssueSortOptions.RECOMMENDED);
render(<IssueListOverview />, {organization: featureOrg, initialRouterConfig});

expect(
await screen.findByRole('button', {name: /Recommended/})
).toBeInTheDocument();
expect(screen.queryByLabelText('new')).not.toBeInTheDocument();

// The Recommended option inside the dropdown keeps its badge
await userEvent.click(screen.getByRole('button', {name: /Recommended/}));
const recommendedOption = screen.getByRole('option', {name: /Recommended/});
expect(within(recommendedOption).getByLabelText('new')).toBeInTheDocument();
});
});

describe('transitionTo', () => {
Expand Down
Loading