Skip to content

Commit

Permalink
fix(explore): Allow deleting last selected group by (#77451)
Browse files Browse the repository at this point in the history
When there's 1 group by left, the delete button just sets it to none
instead of actually deleting the last dropdown item.
  • Loading branch information
Zylphrex authored Sep 13, 2024
1 parent bd50211 commit 9391f21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion static/app/views/explore/toolbar/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,13 @@ describe('ExploreToolbar', function () {
await userEvent.click(within(section).getAllByLabelText('Remove')[0]);
expect(groupBys).toEqual(['span.description']);

// only one left so cant be deleted
// only 1 left but it's not empty
expect(within(section).getByLabelText('Remove')).toBeEnabled();

await userEvent.click(within(section).getByLabelText('Remove'));
expect(groupBys).toEqual(['']);

// last one and it's empty
expect(within(section).getByLabelText('Remove')).toBeDisabled();
});
});
2 changes: 1 addition & 1 deletion static/app/views/explore/toolbar/toolbarGroupBy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function ToolbarGroupBy({disabled}: ToolbarGroupByProps) {
borderless
icon={<IconDelete />}
size="zero"
disabled={disabled || groupBys.length <= 1}
disabled={disabled || (groupBys.length <= 1 && groupBy === '')}
onClick={() => deleteGroupBy(index)}
aria-label={t('Remove')}
/>
Expand Down

0 comments on commit 9391f21

Please sign in to comment.