Skip to content

Commit debe7ac

Browse files
fix(Alert): rename alert close reason
1 parent 381a191 commit debe7ac

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/vkui/src/components/Alert/Alert.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('Alert', () => {
8989
expect(onClosed).toHaveBeenCalledTimes(1);
9090
});
9191

92-
it('calls onClose with "item-click" when clicking action', async () => {
92+
it('calls onClose with "click-item" when clicking action', async () => {
9393
const onClose = vi.fn();
9494
const onClosed = vi.fn();
9595
const result = render(
@@ -110,7 +110,7 @@ describe('Alert', () => {
110110

111111
await userEvent.click(result.getByTestId('__action__'));
112112
expect(onClose).toHaveBeenCalledTimes(1);
113-
expect(onClose).toHaveBeenCalledWith('item-click');
113+
expect(onClose).toHaveBeenCalledWith('click-item');
114114
await waitCSSKeyframesAnimation(result.getByRole('alertdialog'), {
115115
runOnlyPendingTimers: true,
116116
});
@@ -179,7 +179,7 @@ describe('Alert', () => {
179179
expect(onClosed).toHaveBeenCalledTimes(1);
180180
});
181181

182-
it('calls onClose with "item-click" when action with autoCloseDisabled calls close', async () => {
182+
it('calls onClose with "click-item" when action with autoCloseDisabled calls close', async () => {
183183
const onClose = vi.fn();
184184
const onClosed = vi.fn();
185185
const action = vi.fn((args) => {
@@ -208,7 +208,7 @@ describe('Alert', () => {
208208
await userEvent.click(result.getByTestId('__action__'));
209209
expect(action).toHaveBeenCalledTimes(1);
210210
expect(onClose).toHaveBeenCalledTimes(1);
211-
expect(onClose).toHaveBeenCalledWith('item-click');
211+
expect(onClose).toHaveBeenCalledWith('click-item');
212212
await waitCSSKeyframesAnimation(result.getByRole('alertdialog'), {
213213
runOnlyPendingTimers: true,
214214
});

packages/vkui/src/components/Alert/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type AlertActionMode = 'cancel' | 'destructive' | 'default';
2121

2222
export type { AlertActionProps };
2323

24-
export type AlertCloseReason = 'click-overlay' | 'item-click' | 'escape-key' | 'click-close-button';
24+
export type AlertCloseReason = 'click-overlay' | 'click-item' | 'escape-key' | 'click-close-button';
2525

2626
export interface AlertActionInterface
2727
extends Pick<ButtonProps, 'Component'>,

packages/vkui/src/components/Alert/AlertBase.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ export const AlertBase = ({
8686
const { action: itemAction, autoCloseDisabled = false } = item;
8787

8888
if (autoCloseDisabled) {
89-
itemAction && itemAction({ close: () => close('item-click') });
89+
itemAction && itemAction({ close: () => close('click-item') });
9090
} else {
9191
if (itemAction) {
9292
itemActionCallbackRef.current = itemAction;
9393
}
94-
close('item-click');
94+
close('click-item');
9595
}
9696
},
9797
[close],

0 commit comments

Comments
 (0)