diff --git a/CHANGELOG.md b/CHANGELOG.md index a4153680ad6..04ca018c2f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) +- Added `EuiDataGrid`'s default sort order property ([#2987](https://github.com/elastic/eui/pull/2987)) - Fixed `EuiDataGrid`'s pagination visibility when changing rows per page ([#2978](https://github.com/elastic/eui/pull/2978)) - Added `highlightAll` prop to `EuiHighlight` to highlight all matches ([#2957](https://github.com/elastic/eui/pull/2957)) - Added `showOnFocus` prop to `EuiScreenReaderOnly` to force display on keyboard focus ([#2976](https://github.com/elastic/eui/pull/2976)) diff --git a/src-docs/src/views/datagrid/datagrid.js b/src-docs/src/views/datagrid/datagrid.js index 06e5ca0d9aa..440cc1b8406 100644 --- a/src-docs/src/views/datagrid/datagrid.js +++ b/src-docs/src/views/datagrid/datagrid.js @@ -21,6 +21,7 @@ import { const columns = [ { id: 'name', + defaultSortDirection: 'asc', }, { id: 'email', @@ -49,6 +50,7 @@ const columns = [ }, { id: 'date', + defaultSortDirection: 'desc', }, { id: 'amount', @@ -59,6 +61,7 @@ const columns = [ }, { id: 'version', + defaultSortDirection: 'desc', initialWidth: 65, isResizable: false, }, diff --git a/src/components/datagrid/column_sorting.tsx b/src/components/datagrid/column_sorting.tsx index 605d90785d6..f56b15203e5 100644 --- a/src/components/datagrid/column_sorting.tsx +++ b/src/components/datagrid/column_sorting.tsx @@ -34,7 +34,6 @@ export const useColumnSorting = ( ): ReactNode => { const [isOpen, setIsOpen] = useState(false); const [avilableColumnsisOpen, setAvailableColumnsIsOpen] = useState(false); - // prune any non-existant/hidden columns from sorting useEffect(() => { if (sorting) { @@ -213,50 +212,62 @@ export const useColumnSorting = (