From 41bd5a669c0f688b3a97f6344a8401658aa96184 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 19 Nov 2024 03:53:42 +1100 Subject: [PATCH] [8.16] Search fix documents table a11y (#200232) (#200585) # Backport This will backport the following commits from `main` to `8.16`: - [Search fix documents table a11y (#200232)](https://github.com/elastic/kibana/pull/200232) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Sander Philipse <94373878+sphilipse@users.noreply.github.com> --- .../components/result/result.tsx | 1 + .../components/result/result_field.tsx | 57 ++++++++++++------- .../components/result/results_fields.tsx | 26 ++++++++- .../kbn-search-index-documents/tsconfig.json | 1 - 4 files changed, 61 insertions(+), 24 deletions(-) diff --git a/packages/kbn-search-index-documents/components/result/result.tsx b/packages/kbn-search-index-documents/components/result/result.tsx index 14b6c58ebf861..207a4770b97f2 100644 --- a/packages/kbn-search-index-documents/components/result/result.tsx +++ b/packages/kbn-search-index-documents/components/result/result.tsx @@ -121,6 +121,7 @@ export const Result: React.FC = ({ diff --git a/packages/kbn-search-index-documents/components/result/result_field.tsx b/packages/kbn-search-index-documents/components/result/result_field.tsx index e82991032afbc..acd495f71cd44 100644 --- a/packages/kbn-search-index-documents/components/result/result_field.tsx +++ b/packages/kbn-search-index-documents/components/result/result_field.tsx @@ -7,11 +7,19 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import React from 'react'; +import React, { useState } from 'react'; -import { EuiTableRow, EuiTableRowCell, EuiText, EuiToken } from '@elastic/eui'; +import { + EuiButtonIcon, + EuiFlexGroup, + EuiFlexItem, + EuiPopover, + EuiTableRow, + EuiTableRowCell, + EuiText, +} from '@elastic/eui'; -import { euiThemeVars } from '@kbn/ui-theme'; +import { i18n } from '@kbn/i18n'; import { ResultFieldProps } from './result_types'; import { PERMANENTLY_TRUNCATED_FIELDS } from './constants'; import { ResultFieldValue } from './result_field_value'; @@ -63,26 +71,35 @@ export const ResultField: React.FC = ({ isExpanded, }) => { const shouldTruncate = !isExpanded || PERMANENTLY_TRUNCATED_FIELDS.includes(fieldType); + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + const fieldTypeLabel = i18n.translate('searchIndexDocuments.result.fieldTypeAriaLabel', { + defaultMessage: 'This field is of the type {fieldType}', + values: { fieldType }, + }); return ( - - - - - - - - {fieldName} - + + + + setIsPopoverOpen(!isPopoverOpen)} + iconType={iconType || (fieldType ? iconMap[fieldType] : defaultToken)} + /> + } + isOpen={isPopoverOpen} + > + {fieldTypeLabel} + + + + + {fieldName} + + + diff --git a/packages/kbn-search-index-documents/components/result/results_fields.tsx b/packages/kbn-search-index-documents/components/result/results_fields.tsx index e25ede0fe0463..9684d41d28c6b 100644 --- a/packages/kbn-search-index-documents/components/result/results_fields.tsx +++ b/packages/kbn-search-index-documents/components/result/results_fields.tsx @@ -9,19 +9,39 @@ import React from 'react'; -import { EuiTable, EuiTableBody } from '@elastic/eui'; +import { EuiTable, EuiTableBody, EuiTableHeader, EuiTableHeaderCell } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { ResultField } from './result_field'; import { ResultFieldProps } from './result_types'; interface Props { + documentId: string; fields: ResultFieldProps[]; isExpanded: boolean; } -export const ResultFields: React.FC = ({ fields, isExpanded }) => { +export const ResultFields: React.FC = ({ documentId, fields, isExpanded }) => { return ( - + + + + {i18n.translate('searchIndexDocuments.resultFields.fieldTypeHeaderLabel', { + defaultMessage: 'Field', + })} + + + {i18n.translate('searchIndexDocuments.resultFields.contentstableHeaderLabel', { + defaultMessage: 'Contents', + })} + + + {fields.map((field) => (