Skip to content

Commit

Permalink
Fix datatables when no results found (#114)
Browse files Browse the repository at this point in the history
* Update to 1.7.0

* Fix datatable disappearing when no results found
  • Loading branch information
dgading authored Feb 8, 2021
1 parent 5a4d5f0 commit 35db885
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@civicactions/data-catalog-components",
"version": "1.6.0",
"version": "1.7.0",
"description": "React Components for Open Data Catalogs.",
"main": "lib/index.js",
"repository": {
Expand Down
8 changes: 7 additions & 1 deletion src/templates/DataTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const DataTable = () => {
}
}, [resourceState.store, filters]);

if (!reactTable.data.length) {
if (!reactTable.columns.length) {
return null;
}

Expand Down Expand Up @@ -103,6 +103,12 @@ const DataTable = () => {
))}
</div>
<div {...getTableBodyProps()} className="dc-tbody">
{page.length <= 0
&&(
<div className="tr dc-tr" style={{textAlign: 'center'}}>
No results found.
</div>)
}
{page.map((row) => {
prepareRow(row);
return (
Expand Down
2 changes: 1 addition & 1 deletion src/templates/DataTableHeader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import DataIcon from '../../components/DataIcon';
const DataTableHeader = () => {
const { reactTable, resourceState, dispatch } = React.useContext(ResourceDispatch);

if (!reactTable.data.length) {
if (!reactTable.columns.length) {
return null;
}
return (
Expand Down

0 comments on commit 35db885

Please sign in to comment.