Skip to content

Commit a784306

Browse files
committed
Address PR commets
Signed-off-by: Milos Dzepina <milos@aragon.org>
1 parent cc8fca0 commit a784306

3 files changed

Lines changed: 17 additions & 28 deletions

File tree

src/core/components/dropdown/dropdownItem/dropdownItem.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ export const DropdownItem: React.FC<IDropdownItemProps> = (props) => {
8383
};
8484
}
8585

86+
const handleSelect = (event: Event) => {
87+
// For submit buttons, we need to prevent the dropdown from closing immediately to allow the form submission to complete properly
88+
if (renderSubmitButton) {
89+
event.preventDefault();
90+
}
91+
92+
props.onSelect?.(event);
93+
};
94+
8695
const defaultIcon = renderLink ? IconType.LINK_EXTERNAL : selected ? IconType.CHECKMARK : undefined;
8796
const processedIcon = icon ?? defaultIcon;
8897

@@ -102,14 +111,7 @@ export const DropdownItem: React.FC<IDropdownItemProps> = (props) => {
102111
{ 'flex-row-reverse justify-end': iconPosition === 'left' && icon != null },
103112
className,
104113
)}
105-
onSelect={(event) => {
106-
// For submit buttons, we need to prevent the dropdown from closing immediately to allow the form submission to complete properly
107-
if (renderSubmitButton) {
108-
event.preventDefault();
109-
}
110-
111-
props.onSelect?.(event);
112-
}}
114+
onSelect={handleSelect}
113115
{...otherProps}
114116
>
115117
<ItemWrapper {...itemWrapperProps}>

src/modules/components/action/actionSimulation/actionSimulation.test.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { render, screen } from '@testing-library/react';
2-
import { DateTime } from 'luxon';
32
import { GukCoreProvider } from '../../../../core';
43
import { modulesCopy } from '../../../assets';
54
import { ActionSimulation } from './actionSimulation';
@@ -47,11 +46,7 @@ describe('<ActionSimulation /> component', () => {
4746
it('renders the execution status label', () => {
4847
render(
4948
createTestComponent({
50-
lastSimulation: {
51-
timestamp: DateTime.now().toMillis(),
52-
url: 'https://dashboard.tenderly.co/simulation/12345',
53-
status: 'success',
54-
},
49+
lastSimulation: { timestamp: 0, url: '', status: 'success' },
5550
}),
5651
);
5752
expect(screen.getByText(actionSimulationCopy.likelyToSucceed)).toBeInTheDocument();
@@ -60,11 +55,7 @@ describe('<ActionSimulation /> component', () => {
6055
it('renders failure status label', () => {
6156
render(
6257
createTestComponent({
63-
lastSimulation: {
64-
timestamp: DateTime.now().toMillis(),
65-
url: 'https://dashboard.tenderly.co/simulation/12345',
66-
status: 'failed',
67-
},
58+
lastSimulation: { timestamp: 0, url: '', status: 'failed' },
6859
}),
6960
);
7061
expect(screen.getByText(actionSimulationCopy.likelyToFail)).toBeInTheDocument();
@@ -76,24 +67,20 @@ describe('<ActionSimulation /> component', () => {
7667
});
7768

7869
it('renders loading state when execution status is loading', () => {
79-
render(
80-
createTestComponent({
81-
isLoading: true,
82-
}),
83-
);
70+
render(createTestComponent({ isLoading: true }));
8471

8572
expect(screen.getAllByText(actionSimulationCopy.simulating)).toHaveLength(3);
8673
});
8774

88-
it('shows simulate button by default when isSimulatable is not specified', () => {
75+
it('shows simulate button by default when isEnabled is not specified', () => {
8976
render(createTestComponent());
9077

9178
expect(screen.getByText(actionSimulationCopy.simulate)).toBeInTheDocument();
9279
});
9380

94-
it('hides simulate button when isSimulatable is false', () => {
81+
it('hides simulate button when isEnabled is false', () => {
9582
render(createTestComponent({ isEnabled: false }));
9683

97-
expect(screen.queryByText(actionSimulationCopy.simulate)).toBeNull();
84+
expect(screen.queryByText(actionSimulationCopy.simulate)).not.toBeInTheDocument();
9885
});
9986
});

src/modules/components/action/actionSimulation/actionSimulation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const ActionSimulation: React.FC<IActionSimulationProps> = (props) => {
8181
<div className="flex size-6 items-center justify-center">
8282
<AvatarIcon icon={statusConfig.icon} size="sm" variant={statusConfig.variant} />
8383
</div>
84-
<span className={classNames('text-sm', statusConfig.textColor)}>
84+
<span className={classNames('text-sm md:text-base', statusConfig.textColor)}>
8585
{statusConfig.label}
8686
</span>
8787
</>

0 commit comments

Comments
 (0)