diff --git a/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/Pagination/PaginationInput.jsx b/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/Pagination/PaginationInput.jsx index 0d377c2fec..67f1b34718 100644 --- a/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/Pagination/PaginationInput.jsx +++ b/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/Pagination/PaginationInput.jsx @@ -26,12 +26,14 @@ export const PaginationInput = memo(({ pageIndex, serverSidePagination, pageCoun value={inputValue} onChange={(event) => { const value = event.target.value; - setInputValue(value); // Only update page if value is a valid number and within range const pageNumber = parseInt(value, 10); - if (!isNaN(pageNumber) || pageNumber < 1 || pageNumber > pageCount) { + if (!isNaN(pageNumber) && pageNumber >= 1 && pageNumber <= pageCount) { + setInputValue(pageNumber); gotoPage(pageNumber); + } else if (value === '') { + setInputValue(''); } }} /> diff --git a/frontend/src/AppBuilder/Widgets/NewTable/_components/TableData/_components/TableRow.jsx b/frontend/src/AppBuilder/Widgets/NewTable/_components/TableData/_components/TableRow.jsx index b716481c8f..9f61bd0ae3 100644 --- a/frontend/src/AppBuilder/Widgets/NewTable/_components/TableData/_components/TableRow.jsx +++ b/frontend/src/AppBuilder/Widgets/NewTable/_components/TableData/_components/TableRow.jsx @@ -103,6 +103,13 @@ export const TableRow = ({ // to avoid on click event getting propagating to row when td is editable or has action button and allowSelection is true and selectRowOnCellEdit is false e.stopPropagation(); } + setExposedVariables({ + selectedCell: { + columnName: cell.column.columnDef?.header, + columnKey: cell.column.columnDef?.accessorKey, + value: cell.getValue(), + }, + }); }} >
{ - if (allowSelection) { + if (allowSelection && showBulkSelector) { setExposedVariables({ selectedRows: selectedRows.map((row) => row.original), selectedRowsId: selectedRows.map((row) => row.id), - selectedRow: lastClickedRow, - selectedRowId: isNaN(lastClickedRow?.id) ? String(lastClickedRow?.id) : lastClickedRow?.id, }); } else { setExposedVariables({ selectedRows: [], selectedRowsId: [], - selectedRow: {}, - selectedRowId: null, }); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [selectedRows, allowSelection, setExposedVariables, fireEvent, lastClickedRow]); // Didn't add mounted as it's not a dependency + }, [selectedRows, allowSelection, setExposedVariables, fireEvent, lastClickedRow, showBulkSelector]); // Didn't add mounted as it's not a dependency useEffect(() => { if (allowSelection) { @@ -213,6 +209,10 @@ export const TableExposedVariables = ({ if (item) { setRowSelection({ [item.id - 1]: true }); } + setExposedVariables({ + selectedRow: item, + selectedRowId: isNaN(item?.id) ? String(item?.id) : item?.id, + }); } if (defaultSelectedRow) { const key = Object?.keys(defaultSelectedRow)[0] ?? ''; @@ -220,8 +220,22 @@ export const TableExposedVariables = ({ if (key && value) { selectRow(key, value); } + } else { + setExposedVariables({ + selectedRow: {}, + selectedRowId: null, + }); } - }, [data, defaultSelectedRow, setRowSelection]); + }, [data, defaultSelectedRow, setExposedVariables, setRowSelection]); + + useEffect(() => { + if (lastClickedRow) { + setExposedVariables({ + selectedRow: lastClickedRow, + selectedRowId: isNaN(lastClickedRow?.id) ? String(lastClickedRow?.id) : lastClickedRow?.id, + }); + } + }, [lastClickedRow, setExposedVariables]); useEffect(() => { function selectRow(key, value) {