Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

**Bug fixes**

- Fixed `EuiDataGrid` breaking if invalid schema passed ([#2955](https://github.com/elastic/eui/pull/2955))
- Fixed `EuiTitle` not rendering child classes ([#2925](https://github.com/elastic/eui/pull/2925))
- Extended `div` element in `EuiFlyout` type ([#2914](https://github.com/elastic/eui/pull/2914))
- Fixed popover positioning service to be more lenient when positioning 0-width or 0-height content ([#2948](https://github.com/elastic/eui/pull/2948))
Expand Down
20 changes: 13 additions & 7 deletions src/components/datagrid/column_sorting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,18 @@ export const useColumnSorting = (

const numberOfSortedFields = sorting.columns.length;

const inactiveSortableColumns = inactiveColumns.filter(({ id, isSortable }) =>
const schemaDetails = (id: string | number) =>
schema.hasOwnProperty(id) && schema[id].columnType != null
? getDetailsForSchema(schemaDetectors, schema[id].columnType).isSortable
: isSortable !== false
? getDetailsForSchema(schemaDetectors, schema[id].columnType)
: null;

const inactiveSortableColumns = inactiveColumns.filter(
({ id, isSortable }) => {
const schemaDetail = schemaDetails(id);
const sortable =
schemaDetail != null ? schemaDetail.isSortable : isSortable !== false;
Comment thread
ashikmeerankutty marked this conversation as resolved.
Outdated
return sortable;
}
);

const columnSorting = (
Expand Down Expand Up @@ -221,17 +229,15 @@ export const useColumnSorting = (
<EuiFlexItem grow={false}>
<EuiToken
iconType={
schema.hasOwnProperty(id) &&
schema[id].columnType != null
schemaDetails(id) != null
? getDetailsForSchema(
schemaDetectors,
schema[id].columnType
).icon
: 'tokenString'
}
color={
schema.hasOwnProperty(id) &&
schema[id].columnType != null
schemaDetails(id) != null
? getDetailsForSchema(
schemaDetectors,
schema[id].columnType
Expand Down
29 changes: 11 additions & 18 deletions src/components/datagrid/column_sorting_draggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ export interface EuiDataGridColumnSortingDraggableProps {
export const EuiDataGridColumnSortingDraggable: FunctionComponent<
EuiDataGridColumnSortingDraggableProps
> = ({ id, direction, index, sorting, schema, schemaDetectors, ...rest }) => {
const schemaDetails =
schema.hasOwnProperty(id) && schema[id].columnType != null
? getDetailsForSchema(schemaDetectors, schema[id].columnType)
: null;

const textSortAsc =
schema.hasOwnProperty(id) && schema[id].columnType != null ? (
getDetailsForSchema(schemaDetectors, schema[id].columnType).sortTextAsc
schemaDetails != null ? (
schemaDetails.sortTextAsc
) : (
<EuiI18n token="euiColumnSortingDraggable.defaultSortAsc" default="A-Z" />
);

const textSortDesc =
schema.hasOwnProperty(id) && schema[id].columnType != null ? (
getDetailsForSchema(schemaDetectors, schema[id].columnType).sortTextDesc
schemaDetails != null ? (
schemaDetails.sortTextDesc
) : (
<EuiI18n
token="euiColumnSortingDraggable.defaultSortDesc"
Expand Down Expand Up @@ -108,21 +113,9 @@ export const EuiDataGridColumnSortingDraggable: FunctionComponent<

<EuiFlexItem grow={false}>
<EuiToken
color={
schema.hasOwnProperty(id) && schema[id].columnType != null
? getDetailsForSchema(
schemaDetectors,
schema[id].columnType
).color
: undefined
}
color={schemaDetails != null ? schemaDetails.color : undefined}
iconType={
schema.hasOwnProperty(id) && schema[id].columnType != null
? getDetailsForSchema(
schemaDetectors,
schema[id].columnType
).icon
: 'tokenString'
schemaDetails != null ? schemaDetails.icon : 'tokenString'
}
/>
</EuiFlexItem>
Expand Down