mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
[HotFix] Set table action usability issues (#1923)
* Expose setPage action of table on application load itself * Coalesce target pageIndex to 1 for set table page action * Do not fire onPageChanged for set table page action * Change exposed pageIndex when set table page action is fired * Use setExposedVariable to set pageIndex on set table page action * Do not display functions on side bar inspector
This commit is contained in:
parent
f96ab6f795
commit
17fdf58cef
3 changed files with 10 additions and 6 deletions
|
|
@ -39,6 +39,7 @@ export function Table({
|
|||
onComponentOptionsChanged,
|
||||
darkMode,
|
||||
fireEvent,
|
||||
setExposedVariable,
|
||||
registerAction,
|
||||
}) {
|
||||
const color = component.definition.styles.textColor.value;
|
||||
|
|
@ -747,13 +748,16 @@ export function Table({
|
|||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const registerSetPageAction = () => {
|
||||
registerAction('setPage', (targetPageIndex) => {
|
||||
setPaginationInternalPageIndex(targetPageIndex);
|
||||
onPageIndexChanged(targetPageIndex);
|
||||
setExposedVariable('pageIndex', targetPageIndex);
|
||||
if (!serverSidePagination && clientSidePagination) gotoPage(targetPageIndex - 1);
|
||||
});
|
||||
}, [serverSidePagination, clientSidePagination]);
|
||||
};
|
||||
|
||||
useEffect(registerSetPageAction, []);
|
||||
useEffect(registerSetPageAction, [serverSidePagination, clientSidePagination]);
|
||||
|
||||
useEffect(() => {
|
||||
const selectedRowsOriginalData = selectedFlatRows.map((row) => row.original);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export const LeftSidebarInspector = ({ darkMode, globals, components, queries })
|
|||
collapseStringsAfterLength={1000}
|
||||
/>
|
||||
<ReactJson
|
||||
src={components}
|
||||
src={JSON.parse(JSON.stringify(components))}
|
||||
theme={darkMode ? 'shapeshifter' : 'rjv-default'}
|
||||
name={'components'}
|
||||
style={{ fontSize: '0.7rem' }}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ function executeAction(_ref, event, mode) {
|
|||
}
|
||||
|
||||
case 'set-table-page': {
|
||||
setTablePageIndex(_ref, event.table, event.pageIndex);
|
||||
return setTablePageIndex(_ref, event.table, event.pageIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -691,7 +691,7 @@ function setTablePageIndex(_ref, table, index) {
|
|||
|
||||
const tableMeta = _ref.state.currentState.components[table.name];
|
||||
const newPageIndex = resolveReferences(index, _ref.state.currentState);
|
||||
tableMeta.setPage(newPageIndex);
|
||||
tableMeta.setPage(newPageIndex ?? 1);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue