Skip to content

Commit 14c01d8

Browse files
fix(billing): Subscription UI misalignment
1 parent 3fc672d commit 14c01d8

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

static/gsApp/views/subscriptionPage/usageOverview/components/table.spec.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
SubscriptionFixture,
77
SubscriptionWithLegacySeerFixture,
88
} from 'getsentry-test/fixtures/subscription';
9-
import {render, screen, within} from 'sentry-test/reactTestingLibrary';
9+
import {render, screen, userEvent, within} from 'sentry-test/reactTestingLibrary';
1010

1111
import {DataCategory} from 'sentry/types/core';
1212

@@ -48,6 +48,27 @@ describe('UsageOverviewTable', () => {
4848
).toBeGreaterThan(0);
4949
});
5050

51+
it('does not add an extra cell when hovering a product row', async () => {
52+
render(
53+
<UsageOverviewTable
54+
subscription={subscription}
55+
organization={organization}
56+
usageData={usageData}
57+
onRowClick={jest.fn()}
58+
selectedProduct={DataCategory.ERRORS}
59+
/>
60+
);
61+
62+
await screen.findByRole('columnheader', {name: 'Feature'});
63+
64+
const attachmentsRow = screen.getByTestId('product-row-attachments');
65+
expect(within(attachmentsRow).getAllByRole('cell')).toHaveLength(3);
66+
67+
await userEvent.hover(attachmentsRow);
68+
69+
expect(within(attachmentsRow).getAllByRole('cell')).toHaveLength(3);
70+
});
71+
5172
it('renders columns for non-billing users', async () => {
5273
organization.access = [];
5374
render(

static/gsApp/views/subscriptionPage/usageOverview/components/tableRow.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Fragment, useState} from 'react';
1+
import {Fragment} from 'react';
22
import {useTheme} from '@emotion/react';
33
import styled from '@emotion/styled';
44

@@ -74,7 +74,6 @@ export function UsageOverviewTableRow({
7474
const showPanelInline = useMedia(
7575
`(max-width: calc(${theme.breakpoints[SIDE_PANEL_MIN_SCREEN_BREAKPOINT]} - 1px))`
7676
);
77-
const [isHovered, setIsHovered] = useState(false);
7877
const showAdditionalSpendColumn =
7978
subscription.canSelfServe || supportsPayg(subscription);
8079

@@ -238,8 +237,6 @@ export function UsageOverviewTableRow({
238237
<Fragment>
239238
<ProductRow
240239
data-test-id={`product-row-${product}`}
241-
onMouseEnter={() => setIsHovered(true)}
242-
onMouseLeave={() => setIsHovered(false)}
243240
isSelected={isSelected}
244241
onClick={() => onRowClick(product)}
245242
onKeyDown={e => {
@@ -355,8 +352,6 @@ export function UsageOverviewTableRow({
355352
</td>
356353
) : null}
357354
</Fragment>
358-
359-
{(isSelected || isHovered) && <SelectedPill isSelected={isSelected} />}
360355
</ProductRow>
361356
{showPanelInline && isSelected && (
362357
<Row>
@@ -386,14 +381,11 @@ function DisabledProductRow({
386381
usageData,
387382
subscription,
388383
}: DisabledProductRowProps) {
389-
const [isHovered, setIsHovered] = useState(false);
390384
const isSelected = selectedProduct === product;
391385
return (
392386
<Fragment>
393387
<ProductRow
394388
data-test-id={`product-row-disabled-${product}`}
395-
onMouseEnter={() => setIsHovered(true)}
396-
onMouseLeave={() => setIsHovered(false)}
397389
isSelected={isSelected}
398390
onClick={() => onRowClick(product)}
399391
onKeyDown={e => {
@@ -448,7 +440,6 @@ function DisabledProductRow({
448440
</td>
449441
</Fragment>
450442
)}
451-
{(isSelected || isHovered) && <SelectedPill isSelected={isSelected} />}
452443
</ProductRow>
453444
{showPanelInline && isSelected && (
454445
<Row>
@@ -493,6 +484,26 @@ const ProductRow = styled(Row)<{isSelected: boolean}>`
493484
&:active {
494485
background: ${p => p.theme.tokens.interactive.transparent.neutral.background.active};
495486
}
487+
488+
&::after {
489+
content: '';
490+
position: absolute;
491+
right: -1px;
492+
top: 30%;
493+
width: 4px;
494+
height: 22px;
495+
border-radius: 2px;
496+
background: ${p =>
497+
p.isSelected
498+
? p.theme.tokens.graphics.accent.vibrant
499+
: p.theme.tokens.graphics.neutral.moderate};
500+
opacity: ${p => (p.isSelected ? 1 : 0)};
501+
pointer-events: none;
502+
}
503+
504+
&:hover::after {
505+
opacity: 1;
506+
}
496507
`;
497508

498509
const MobilePanelContainer = styled('td')`
@@ -501,19 +512,6 @@ const MobilePanelContainer = styled('td')`
501512
grid-column: 1 / -1;
502513
`;
503514

504-
const SelectedPill = styled('td')<{isSelected: boolean}>`
505-
position: absolute;
506-
right: -1px;
507-
top: 30%;
508-
width: 4px;
509-
height: 22px;
510-
border-radius: 2px;
511-
background: ${p =>
512-
p.isSelected
513-
? p.theme.tokens.graphics.accent.vibrant
514-
: p.theme.tokens.graphics.neutral.moderate};
515-
`;
516-
517515
const IconContainer = styled('span')`
518516
display: inline-block;
519517
vertical-align: middle;

0 commit comments

Comments
 (0)