diff --git a/static/app/views/explore/toolbar/index.spec.tsx b/static/app/views/explore/toolbar/index.spec.tsx index c9412146b499ec..ef7132929343b9 100644 --- a/static/app/views/explore/toolbar/index.spec.tsx +++ b/static/app/views/explore/toolbar/index.spec.tsx @@ -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(); }); }); diff --git a/static/app/views/explore/toolbar/toolbarGroupBy.tsx b/static/app/views/explore/toolbar/toolbarGroupBy.tsx index cee5ed73105c3e..f466615f71e194 100644 --- a/static/app/views/explore/toolbar/toolbarGroupBy.tsx +++ b/static/app/views/explore/toolbar/toolbarGroupBy.tsx @@ -89,7 +89,7 @@ export function ToolbarGroupBy({disabled}: ToolbarGroupByProps) { borderless icon={} size="zero" - disabled={disabled || groupBys.length <= 1} + disabled={disabled || (groupBys.length <= 1 && groupBy === '')} onClick={() => deleteGroupBy(index)} aria-label={t('Remove')} />