Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #627, #614 #638

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.8'
node-version: '22.6'
cache: yarn
- name: Restore cache
uses: actions/cache@v4
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
The following is a list of notable changes to the Mantine DataTable component.
Minor versions that are not listed in the changelog are bug fixes and small improvements.

## 7.12.4 (2024-09-04)

- Fix [#627](https://github.com/icflorescu/mantine-datatable/issues/627)
- Fix [#614](https://github.com/icflorescu/mantine-datatable/issues/614)

## 7.12.3 (2024-09-04)

- Fix [#625](https://github.com/icflorescu/mantine-datatable/issues/625) - after implementing row dragging support, inputs inside columns were losing focus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import { Button, Group, Stack, Text } from '@mantine/core';
import { IconBuildingCommunity, IconBuildingSkyscraper, IconMap, IconRoadSign } from '@tabler/icons-react';
import { DataTable, useDataTableColumns } from '__PACKAGE__';
import { DataTable, DataTableColumn, useDataTableColumns } from '__PACKAGE__';
import { useState } from 'react';
import { companies } from '~/data';
import { DataTableColumn } from '~/dist';

export default function DynamicColumnExample() {
const key = 'dynamic-column-example';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable",
"version": "7.12.3",
"version": "7.12.4",
"description": "The lightweight, dependency-free, dark-theme aware table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagination, intuitive Gmail-style additive batch rows selection, column sorting, custom cell data rendering, row expansion, nesting, context menus, and much more",
"keywords": [
"mantine",
Expand Down
12 changes: 5 additions & 7 deletions package/DataTablePagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ export const DataTablePagination = forwardRef(function DataTablePagination(
ref: ForwardedRef<HTMLDivElement>
) {
let paginationTextValue: React.ReactNode;
if (fetching) {
paginationTextValue = loadingText;
} else if (!totalRecords) {
paginationTextValue = noRecordsText;
} else {
const from = (page! - 1) * recordsPerPage! + 1;
const to = from + recordsLength! - 1;
if (totalRecords) {
const from = (page - 1) * recordsPerPage + 1;
const to = from + (recordsLength || 0) - 1;
paginationTextValue = paginationText!({ from, to, totalRecords });
} else {
paginationTextValue = fetching ? loadingText : noRecordsText;
}

const isAbovePaginationWrapBreakpoint = useMediaQueryStringOrFunction(
Expand Down
10 changes: 6 additions & 4 deletions package/hooks/useDataTableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ export const useDataTableColumns = <T>({
.map((column) => {
return {
...column,
hidden: !columnsToggle.find((toggle) => {
return toggle.accessor === column?.accessor;
})?.toggled,
hidden:
column?.hidden ||
!columnsToggle.find((toggle) => {
return toggle.accessor === column?.accessor;
})?.toggled,
};
}) as DataTableColumn<T>[];

Expand Down Expand Up @@ -282,4 +284,4 @@ export const useDataTableColumns = <T>({
setColumnWidth,
resetColumnsWidth,
} as const;
};
};