Skip to content

Commit

Permalink
fix: delete comment
Browse files Browse the repository at this point in the history
  • Loading branch information
leleOFA committed Feb 6, 2025
1 parent 48285c0 commit 753d82e
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 109 deletions.
23 changes: 10 additions & 13 deletions packages/pn-commons/src/components/CustomTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const CustomTooltip: React.FC<Props> = ({
onOpen,
tooltipProps,
}) => {
// tooltip state
const [open, setOpen] = useState(false);
const handleTooltipClose = () => {
if (openOnClick) {
Expand All @@ -30,16 +29,14 @@ const CustomTooltip: React.FC<Props> = ({
setOpen(!open);
}
};
const tooltipId = `tooltip-${Math.random().toString(36).substr(2, 9)}`; // Genera un ID unico per ogni tooltip
const tooltipId = `tooltip-${Math.random().toString(36).substr(2, 9)}`;

// Funzione per gestire il focus su tastiera
const handleFocus = () => {
handleTooltipOpen(); // Apre il tooltip quando l'elemento riceve il focus
handleTooltipOpen();
};

// Funzione per gestire il mouseover
const handleMouseOver = () => {
handleTooltipOpen(); // Apre il tooltip quando il mouse passa sopra l'elemento
handleTooltipOpen();
};

return (
Expand All @@ -52,20 +49,20 @@ const CustomTooltip: React.FC<Props> = ({
disableHoverListener={openOnClick}
enterTouchDelay={0}
onOpen={onOpen}
aria-live="polite" // Tooltip letto dal lettore di schermo quando visibile
aria-describedby={open ? tooltipId : undefined} // Associa il tooltip se visibile
aria-live="polite"
aria-describedby={open ? tooltipId : undefined}
{...tooltipProps}
>
{openOnClick
? cloneElement(children, {
onClick: () => handleTooltipOpen(), // Apre il tooltip su click
'aria-describedby': tooltipId, // Associa il tooltip all'elemento
onClick: () => handleTooltipOpen(),
'aria-describedby': tooltipId,
})
: cloneElement(children, {
onFocus: handleFocus, // Apre il tooltip su focus
onMouseOver: handleMouseOver, // Apre il tooltip su mouseover
onFocus: handleFocus,
onMouseOver: handleMouseOver,
'aria-describedby': tooltipId,
tabIndex: 0, // Associa il tooltip all'elemento
tabIndex: 0,
})}
</Tooltip>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,20 @@
import { Box, SxProps, TableCell } from '@mui/material';
/* import { ButtonNaked } from '@pagopa/mui-italia';
import { buttonNakedInheritStyle } from '../../../utility'; */

export type PnTableBodyCellProps = {
testId?: string;
cellProps?: SxProps;
// onClick?: () => void;
children: React.ReactNode;
};

const PnTableBodyCell: React.FC<PnTableBodyCellProps> = ({
testId,
cellProps,
children,
// onClick,
}) => (
const PnTableBodyCell: React.FC<PnTableBodyCellProps> = ({ testId, cellProps, children }) => (
<TableCell
scope="col"
data-testid={testId}
sx={{
...cellProps!,
borderBottom: 'none',
}}
// onClick={onClick}
>
{/* {onClick && (
<>
{/* Even there is a onClick function on the TableCell, leave ButtonNaked below as is.
This makes spacebar key with accessibility to trigger the onClick function.
The ButtonNaked "inherits" the onClick action from the outer TableCell, so that is not necessary to replicate it. }
<ButtonNaked sx={buttonNakedInheritStyle}>{children}</ButtonNaked>
</>
)} */}
{/* !onClick && <Box>{children}</Box> */}
<Box>{children}</Box>
</TableCell>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import PnTableBodyCell from '../PnTableBodyCell';
describe('PnTableBodyCell', () => {
disableConsoleLogging('error');

// const mockFn = vi.fn();

it('render component', () => {
const { container, queryByTestId } = render(
<PnTableBodyCell>mocke-cell-content</PnTableBodyCell>
Expand All @@ -14,18 +12,4 @@ describe('PnTableBodyCell', () => {
const buttons = queryByTestId('cell.button');
expect(buttons).not.toBeInTheDocument();
});

/* it('click cell event', () => {
const { getByTestId } = render(
<PnTableBodyCell
testId="cell"
// onClick={() => mockFn()}
>
mocke-cell-content
</PnTableBodyCell>
);
const cell = getByTestId('cell');
fireEvent.click(cell);
expect(mockFn).toBeCalledTimes(1);
}); */
});
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ describe('SmartData', () => {
const sortToggle = within(table).getByTestId(`headerCellDesktop.sort.${sortableColumn!.id}`);
fireEvent.click(sortToggle);
expect(handleSort).toHaveBeenCalledTimes(1);
/* const clickableColumnIdx = smartCfg.findIndex((cfg) => cfg.tableConfiguration.onClick);
const rows = within(table).getAllByTestId('bodyRowDesktop');
// we can take the row we want
const cells = within(rows[0]).getAllByTestId('rowCellDesktop');
fireEvent.click(cells[clickableColumnIdx]);
expect(handleColumnClick).toHaveBeenCalledTimes(1); */
});

it('no sort available (desktop version)', () => {
Expand Down
37 changes: 2 additions & 35 deletions packages/pn-commons/src/components/Data/__test__/PnTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,6 @@ describe('PnTable Component', () => {
});
});

/* it('sorts a column', () => {
const { getByRole } = render(<RenderPnTable />);
const table = getByRole('table');
const tableHead = within(table).getByTestId('table-test.header');
const firstColumn = within(tableHead).getAllByTestId('table-test.header.cell')[0];
const sortButton = within(firstColumn).getByRole('button');
expect(sortButton).toBeInTheDocument();
fireEvent.click(sortButton);
expect(handleSort).toBeCalledTimes(1);
expect(handleSort).toBeCalledWith({ order: 'desc', orderBy: 'column-1' });
});
it('click on a column', () => {
const { getByRole } = render(<RenderPnTable />);
const table = getByRole('table');
const tableBody = within(table).getByTestId('table-test.body');
const firstRow = within(tableBody).getAllByTestId('table-test.body.row')[0];
const tableColumns = within(firstRow).getAllByTestId('table-test.body.row.cell');
fireEvent.click(tableColumns[2].querySelectorAll('button')[0]);
expect(handleColumnClick).toHaveBeenCalledTimes(1);
expect(handleColumnClick).toHaveBeenCalledWith(rows[0], columns[2].id);
}); */

it('render component - multiple PnTableBody', () => {
expect(() =>
render(
Expand All @@ -133,12 +110,7 @@ describe('PnTable Component', () => {
{rows.map((row, index) => (
<PnTableBodyRow key={row.id} testId="table-test" index={index}>
{columns.map((column) => (
<PnTableBodyCell
key={column.id}
// onClick={() => column.onClick?.()}
>
{row[column.id]}
</PnTableBodyCell>
<PnTableBodyCell key={column.id}>{row[column.id]}</PnTableBodyCell>
))}
</PnTableBodyRow>
))}
Expand All @@ -147,12 +119,7 @@ describe('PnTable Component', () => {
{rows.map((row, index) => (
<PnTableBodyRow key={row.id} testId="table-test" index={index}>
{columns.map((column) => (
<PnTableBodyCell
key={column.id}
// onClick={() => column.onClick?.()}
>
{row[column.id]}
</PnTableBodyCell>
<PnTableBodyCell key={column.id}>{row[column.id]}</PnTableBodyCell>
))}
</PnTableBodyRow>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ const RenderSmartable: React.FC<{
<SmartBodyCell
key={column.id.toString()}
columnId={column.id}
tableProps={
{
// sonClick: column.tableConfiguration.onClick,
}
}
tableProps={{}}
cardProps={column.cardConfiguration}
isCardHeader={column.cardConfiguration?.isCardHeader}
>
Expand Down Expand Up @@ -231,11 +227,7 @@ describe('Smart Table Component', () => {
<SmartBodyCell
key={column.id.toString()}
columnId={column.id}
tableProps={
{
// onClick: column.tableConfiguration.onClick,
}
}
tableProps={{}}
cardProps={column.cardConfiguration}
isCardHeader={column.cardConfiguration?.isCardHeader}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const StatusTooltip = ({
}}
data-testid={`statusChip-${label}`}
aria-label={isMobile ? `${label}: ${tooltip}` : undefined}
aria-describedby={`tooltip-${label}`} // Associa il chip al tooltip
aria-describedby={`tooltip-${label}`}
/>
</CustomTooltip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default function CustomPagination({
: props2.type
}
{...props2}
// sx={{ border: 'none' }}
sx={{ border: 'none' }}
/>
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
PnTableBodyRow,
PnTableHeader,
PnTableHeaderCell,
// Row,
Sort,
} from '@pagopa-pn/pn-commons';

Expand Down Expand Up @@ -154,7 +153,6 @@ const DesktopNotifications = ({

const showFilters = notifications?.length > 0 || filtersApplied;

// Navigation handlers
const handleRowClick = (iun: string) => {
navigate(routes.GET_DETTAGLIO_NOTIFICA_PATH(iun));
};
Expand Down Expand Up @@ -190,10 +188,8 @@ const DesktopNotifications = ({
{columns.map((column) => (
<PnTableBodyCell
key={column.id}
// onClick={() => handleRowClick(row)}
cellProps={{
...column.cellProps,
// cursor: 'pointer',
}}
>
<NotificationsDataSwitch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ const DesktopNotifications = ({

const showFilters = notifications?.length > 0 || filtersApplied;

// Navigation handlers
const handleRowClick = (iun: string, mandateId?: string) => {
if (isDelegatedPage && mandateId) {
navigate(routes.GET_DETTAGLIO_NOTIFICA_DELEGATO_PATH(iun, mandateId));
Expand Down Expand Up @@ -163,10 +162,8 @@ const DesktopNotifications = ({
{columns.map((column) => (
<PnTableBodyCell
key={column.id}
// onClick={() => handleRowClick(row)}
cellProps={{
...column.cellProps,
// cursor: 'pointer',
}}
>
<NotificationsDataSwitch
Expand Down

0 comments on commit 753d82e

Please sign in to comment.