[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:
Sherfin Shamsudeen 2022-01-24 15:37:12 +05:30 committed by GitHub
parent f96ab6f795
commit 17fdf58cef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View file

@ -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);

View file

@ -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' }}

View file

@ -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();
}