Skip to content

Commit

Permalink
fix(table): delete use useOnEventOutside cell renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
trigoporres committed Nov 13, 2024
1 parent b5d1778 commit fa84d9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 5 additions & 9 deletions packages/table/src/core/Cell/useRenderContent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';

import { useOnEventOutside } from '@devoinc/genesys-ui';
import { useClickAway } from 'ahooks';

import type { TColDef, TRow, TRowDef } from '../../declarations';
import { TableContext } from '../../context';
Expand All @@ -10,7 +9,7 @@ export const useRenderContent = (
data: unknown,
rowIndex: number,
row: TRow,
rowDef: TRowDef
rowDef: TRowDef,
) => {
const { onCellDataChange } = React.useContext(TableContext);
const cellRef = React.useRef<HTMLTableCellElement>();
Expand Down Expand Up @@ -44,12 +43,9 @@ export const useRenderContent = (
[colDef.editable],
);

useOnEventOutside({
references: [cellRef, editionContent, viewContent],
handler: () => {
setIsEditMode(false);
},
});
useClickAway(() => {
setIsEditMode(false);
}, [cellRef]);

return {
cellRef,
Expand Down
5 changes: 3 additions & 2 deletions packages/table/src/editors/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const data = Holo.of()
Holo.chance.pickone(['read', 'view', 'inProgress', 'completed']),
picture: 'avatar',
})
.repeat(9)
.repeat(1)
.generate();

const colDefs: TColDef = [
Expand Down Expand Up @@ -79,9 +79,10 @@ const colDefs: TColDef = [
id={'test'}
label={'custom'}
placeholder={'custom'}
hideLabel
menuAppendToBody
onChange={(event) => {
onChange(event.value)
onChange(event.value);
}}
options={getSelectOptions(options)}
value={String(value)}
Expand Down

0 comments on commit fa84d9b

Please sign in to comment.