Skip to content

Commit c49028a

Browse files
committed
fix(storybook): removeEventListener in useEffect cleanup for table story
1 parent a1a5234 commit c49028a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/stories/Table.stories.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect } from 'react'
22
import { Meta, StoryObj } from '@storybook/react'
3+
import { action } from '@storybook/addon-actions'
34
import {
45
Button,
56
ButtonComponentType,
@@ -22,7 +23,7 @@ import { ReactComponent as ICWarning } from '@Icons/ic-warning-y6.svg'
2223

2324
const CellComponent = ({ field, value, signals, row, isRowActive }: TableCellComponentProps) => {
2425
const handleButtonClick = () => {
25-
alert(`Row ${value} clicked`)
26+
action(`Row ${value} clicked`)
2627
}
2728

2829
useEffect(() => {
@@ -44,7 +45,7 @@ const CellComponent = ({ field, value, signals, row, isRowActive }: TableCellCom
4445
},
4546
}) => {
4647
if (id === row.id && field === 'name') {
47-
alert(text)
48+
action(text)
4849
}
4950
}
5051

@@ -58,7 +59,7 @@ const CellComponent = ({ field, value, signals, row, isRowActive }: TableCellCom
5859
return () => {
5960
signals.removeEventListener(TableSignalEnum.ENTER_PRESSED, rowEnterPressedCallback)
6061
signals.removeEventListener(TableSignalEnum.DELETE_PRESSED, deletePressedCallback)
61-
signals.addEventListener(TableSignalEnum.OPEN_CONTEXT_MENU, openContextMenuCallback)
62+
signals.removeEventListener(TableSignalEnum.OPEN_CONTEXT_MENU, openContextMenuCallback)
6263
}
6364
}, [])
6465

@@ -180,7 +181,7 @@ const BulkActionsComponent = () => (
180181
variant={ButtonVariantType.borderLess}
181182
ariaLabel="Pause"
182183
size={ComponentSizeType.small}
183-
onClick={() => alert('Pause clicked')}
184+
onClick={() => action('Pause clicked')}
184185
showAriaLabelInTippy
185186
/>
186187

@@ -192,7 +193,7 @@ const BulkActionsComponent = () => (
192193
variant={ButtonVariantType.borderLess}
193194
ariaLabel="Play"
194195
size={ComponentSizeType.small}
195-
onClick={() => alert('Play clicked!')}
196+
onClick={() => action('Play clicked!')}
196197
showAriaLabelInTippy
197198
/>
198199
</div>

0 commit comments

Comments
 (0)