From 24233c6df6f6d0a4b6dcc79eea0282fdf2c8590a Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 13 May 2021 17:08:27 -0400 Subject: [PATCH] [Enterprise Search] Fix SchemaFieldTypeSelect axe issues (#100035) (#100069) * Update SchemaFieldTypeSelect to allow passing any aria props - We'll specifically be using aria-labelledby in this PR, but theoretically any aria prop should be fine. * Update AS & WS schema tables to use the type table column heading as an aria-labelledby ID Co-authored-by: Constance --- .../components/schema/components/schema_table.tsx | 5 ++++- .../shared/schema/field_type_select/index.test.tsx | 6 ++++++ .../applications/shared/schema/field_type_select/index.tsx | 2 ++ .../components/schema/schema_fields_table.tsx | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.tsx index d9187bb65adf0..8fff01b268b12 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.tsx @@ -35,7 +35,9 @@ export const SchemaTable: React.FC = () => { {FIELD_NAME} - {FIELD_TYPE} + + {FIELD_TYPE} + @@ -74,6 +76,7 @@ export const SchemaTable: React.FC = () => { fieldName={fieldName} fieldType={fieldType} updateExistingFieldType={updateSchemaFieldType} + aria-labelledby="schemaFieldType" /> diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.test.tsx index df28719839011..6d51a06273712 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.test.tsx @@ -39,4 +39,10 @@ describe('SchemaFieldTypeSelect', () => { expect(wrapper.find(EuiSelect).prop('disabled')).toEqual(true); }); + + it('passes arbitrary props', () => { + const wrapper = shallow(); + + expect(wrapper.find(EuiSelect).prop('aria-label')).toEqual('Test label'); + }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.tsx index 8dfd87f4015d6..fb6c0f2047b12 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/schema/field_type_select/index.tsx @@ -23,10 +23,12 @@ export const SchemaFieldTypeSelect: React.FC = ({ fieldType, updateExistingFieldType, disabled, + ...rest }) => { const fieldTypeOptions = Object.values(SchemaType).map((type) => ({ value: type, text: type })); return ( { {SCHEMA_ERRORS_TABLE_FIELD_NAME_HEADER} - + {SCHEMA_ERRORS_TABLE_DATA_TYPE_HEADER} @@ -58,6 +58,7 @@ export const SchemaFieldsTable: React.FC = () => { fieldName={fieldName} fieldType={filteredSchemaFields[fieldName]} updateExistingFieldType={updateExistingFieldType} + aria-labelledby="schemaDataType" />