-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Search][a11y] Fixing connectors pageHeader hierarchy content #201359
Conversation
Pinging @elastic/kibana-accessibility (Project:Accessibility) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small request; can you provide a gif of you interacting with the title/description just to confirm the functionality still works?
Sure @navarone-feekery : CleanShot.2024-11-22.at.15.13.48.mp4 |
Good point @jedrazb there are still buttons within the
As commented here in the original issue ticket: we, from Search POV, can solve the issue regarding H1 not wrapping the description. But bearing in mind that: <EnterpriseSearchContentPageTemplate
pageChrome={[...connectorsBreadcrumbs, connector?.name ?? '...']}
pageViewTelemetry={tabId}
isLoading={isLoading}
pageHeader={{
description: connector ? <ConnectorDescription connector={connector} /> : '...',
pageTitle: connector ? <ConnectorName connector={connector} /> : '...',
rightSideGroupProps: {
gutterSize: 's',
responsive: false,
wrap: false,
},
rightSideItems: getHeaderActions(index, connector),
tabs: tabs as Array<EuiTabProps & { label: React.ReactNode }>,
}}
>
{selectedTab?.content || null}
</EnterpriseSearchContentPageTemplate>
|
@JoseLuisGJ got it thank you for sharing context, agreed that the fix for the h1 wrap is non-obvious and would involve adapting how page header and edit inline components are designed. If we can navigate the website with keyboard only and have reasonable voice over notifications I guess this should be fine |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code duplication is the issue for me. I don't like that we duplicate most of logic between the _description
and _name
files, I asked copilot to refactor those files and create a HOC, Im sharing the suggestion as I like the structyre (though please validate! as I see that it lost e.g. heading="h1"
prop for title):
HOC component suggestion
import React, { ChangeEvent, useEffect, useState } from 'react';
import { EuiFlexItem, EuiInlineEditText, EuiInlineEditTitle } from '@elastic/eui';
import { useActions, useValues } from 'kea';
import { i18n } from '@kbn/i18n';
import { Connector } from '@kbn/search-connectors';
import { ConnectorNameAndDescriptionLogic } from './connector_name_and_description_logic';
interface ConnectorFieldProps {
connector: Connector;
field: 'name' | 'description'; // The field to edit
isTitle?: boolean; // Whether to render a title (`EuiInlineEditTitle`) or text (`EuiInlineEditText`)
}
export const ConnectorField: React.FC<ConnectorFieldProps> = ({ connector, field, isTitle }) => {
const [value, setValue] = useState<string | null>(connector[field]);
const [resolverObject, setResolverObject] = useState({
rej: () => {},
res: () => {},
});
const { saveNameAndDescription, setConnector } = useActions(ConnectorNameAndDescriptionLogic);
const { status, isLoading, isFailed, isSuccess } = useValues(ConnectorNameAndDescriptionLogic);
useEffect(() => {
setConnector(connector);
}, [connector]);
useEffect(() => {
if (isSuccess) resolverObject.res(true);
if (isFailed) resolverObject.rej();
}, [status]);
const getValidationPromiseResolvers = () => {
const resolvers = {
rej: () => {},
res: () => {},
};
const promise = new Promise((resolve, reject) => {
resolvers.res = resolve;
resolvers.rej = reject;
});
setResolverObject(resolvers);
return promise;
};
const handleSave = async (newValue: string) => {
setValue(newValue);
saveNameAndDescription({ ...connector, [field]: newValue });
return getValidationPromiseResolvers();
};
const handleCancel = (previousValue: string) => {
setValue(previousValue);
};
const Component = isTitle ? EuiInlineEditTitle : EuiInlineEditText;
return (
<EuiFlexItem grow={false}>
<Component
inputAriaLabel={i18n.translate(
`xpack.enterpriseSearch.content.connectors.nameAndDescription.${field}.ariaLabel`,
{
defaultMessage: `Edit connector ${field}`,
}
)}
placeholder={i18n.translate(
`xpack.enterpriseSearch.content.connectors.nameAndDescription.${field}.placeholder`,
{
defaultMessage: field === 'name' ? 'Add a name to your connector' : 'Add a description',
}
)}
value={value || ''}
isLoading={isLoading}
isInvalid={field === 'name' && !value?.trim()}
size="m"
editModeProps={{
cancelButtonProps: { onClick: () => handleCancel(connector[field] || '') },
formRowProps: field === 'name' && !value?.trim() ? {
error: [
i18n.translate(
'xpack.enterpriseSearch.content.nameAndDescription.name.error.empty',
{ defaultMessage: 'Connector name cannot be empty' }
),
],
} : undefined,
inputProps: { readOnly: isLoading },
}}
onSave={handleSave}
onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}
onCancel={() => handleCancel(connector[field] || '')}
/>
</EuiFlexItem>
);
};
and the e.g. connector name def:
import React from 'react';
import { Connector } from '@kbn/search-connectors';
import { ConnectorField } from './ConnectorField';
export const ConnectorName: React.FC<{ connector: Connector }> = ({ connector }) => (
<ConnectorField connector={connector} field="name" isTitle />
);
and description
import React from 'react';
import { Connector } from '@kbn/search-connectors';
import { ConnectorField } from './ConnectorField';
export const ConnectorDescription: React.FC<{ connector: Connector }> = ({ connector }) => (
<ConnectorField connector={connector} field="description" />
);
I am also really away from accessibility/Kibana and do not fully understand what happens here. Why does the accessibility improve? Is it because we now have 2 separate HTML sections that are handled better by the tools that do text-to-voice? |
We no longer wrap description in h1 (page title) tag from what i understand |
Thanks @jedrazb and @artem-shelkovnikov , indeed now H1 tag only renders the Title content and the description inline edit element it below it. @jedrazb I refactored these components using a HOC and sharing code as your suggestion and with the help of Copilot as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, small comment
...ublic/applications/enterprise_search_content/components/connector_detail/connector_field.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for helping with the a11y issues!
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
cc @JoseLuisGJ |
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12033090516 |
…c#201359) Replace the existing `ConnectorNameAndDescription` component with separate `ConnectorName` and `ConnectorDescription` components for improved accessibility as pointed out in this issue elastic#198001 . Now only the H1 wraps the Title and the Descriptions is out of it. Before: ![image](https://github.com/user-attachments/assets/e3b297a9-31e1-4471-a638-2166185551e6) ![image](https://github.com/user-attachments/assets/c9030e25-b067-40b5-b4f6-d07a52d16a30) After: ![CleanShot 2024-11-22 at 12 56 25@2x](https://github.com/user-attachments/assets/41a8cbf9-e609-4fbb-b1cd-3f9256bcaa8e) --------- Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 8487bc8)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…201359) (#201806) # Backport This will backport the following commits from `main` to `8.x`: - [[Search][a11y] Fixing connectors pageHeader hierarchy content (#201359)](#201359) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"José Luis González","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-26T14:48:15Z","message":"[Search][a11y] Fixing connectors pageHeader hierarchy content (#201359)\n\nReplace the existing `ConnectorNameAndDescription` component with\r\nseparate `ConnectorName` and `ConnectorDescription` components for\r\nimproved accessibility as pointed out in this issue\r\nhttps://github.com//issues/198001 . Now only the H1 wraps\r\nthe Title and the Descriptions is out of it.\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/e3b297a9-31e1-4471-a638-2166185551e6)\r\n\r\n![image](https://github.com/user-attachments/assets/c9030e25-b067-40b5-b4f6-d07a52d16a30)\r\n\r\nAfter:\r\n\r\n![CleanShot 2024-11-22 at 12 56\r\n25@2x](https://github.com/user-attachments/assets/41a8cbf9-e609-4fbb-b1cd-3f9256bcaa8e)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"8487bc83d9ebc20ec2e1a5a18286a2a522346e6c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Project:Accessibility","release_note:skip","v9.0.0","Team:Search","backport:prev-minor"],"title":"[Search][a11y] Fixing connectors pageHeader hierarchy content","number":201359,"url":"https://github.com/elastic/kibana/pull/201359","mergeCommit":{"message":"[Search][a11y] Fixing connectors pageHeader hierarchy content (#201359)\n\nReplace the existing `ConnectorNameAndDescription` component with\r\nseparate `ConnectorName` and `ConnectorDescription` components for\r\nimproved accessibility as pointed out in this issue\r\nhttps://github.com//issues/198001 . Now only the H1 wraps\r\nthe Title and the Descriptions is out of it.\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/e3b297a9-31e1-4471-a638-2166185551e6)\r\n\r\n![image](https://github.com/user-attachments/assets/c9030e25-b067-40b5-b4f6-d07a52d16a30)\r\n\r\nAfter:\r\n\r\n![CleanShot 2024-11-22 at 12 56\r\n25@2x](https://github.com/user-attachments/assets/41a8cbf9-e609-4fbb-b1cd-3f9256bcaa8e)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"8487bc83d9ebc20ec2e1a5a18286a2a522346e6c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201359","number":201359,"mergeCommit":{"message":"[Search][a11y] Fixing connectors pageHeader hierarchy content (#201359)\n\nReplace the existing `ConnectorNameAndDescription` component with\r\nseparate `ConnectorName` and `ConnectorDescription` components for\r\nimproved accessibility as pointed out in this issue\r\nhttps://github.com//issues/198001 . Now only the H1 wraps\r\nthe Title and the Descriptions is out of it.\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/e3b297a9-31e1-4471-a638-2166185551e6)\r\n\r\n![image](https://github.com/user-attachments/assets/c9030e25-b067-40b5-b4f6-d07a52d16a30)\r\n\r\nAfter:\r\n\r\n![CleanShot 2024-11-22 at 12 56\r\n25@2x](https://github.com/user-attachments/assets/41a8cbf9-e609-4fbb-b1cd-3f9256bcaa8e)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"8487bc83d9ebc20ec2e1a5a18286a2a522346e6c"}}]}] BACKPORT--> Co-authored-by: José Luis González <[email protected]>
…c#201359) Replace the existing `ConnectorNameAndDescription` component with separate `ConnectorName` and `ConnectorDescription` components for improved accessibility as pointed out in this issue elastic#198001 . Now only the H1 wraps the Title and the Descriptions is out of it. Before: ![image](https://github.com/user-attachments/assets/e3b297a9-31e1-4471-a638-2166185551e6) ![image](https://github.com/user-attachments/assets/c9030e25-b067-40b5-b4f6-d07a52d16a30) After: ![CleanShot 2024-11-22 at 12 56 25@2x](https://github.com/user-attachments/assets/41a8cbf9-e609-4fbb-b1cd-3f9256bcaa8e) --------- Co-authored-by: Elastic Machine <[email protected]>
…c#201359) Replace the existing `ConnectorNameAndDescription` component with separate `ConnectorName` and `ConnectorDescription` components for improved accessibility as pointed out in this issue elastic#198001 . Now only the H1 wraps the Title and the Descriptions is out of it. Before: ![image](https://github.com/user-attachments/assets/e3b297a9-31e1-4471-a638-2166185551e6) ![image](https://github.com/user-attachments/assets/c9030e25-b067-40b5-b4f6-d07a52d16a30) After: ![CleanShot 2024-11-22 at 12 56 25@2x](https://github.com/user-attachments/assets/41a8cbf9-e609-4fbb-b1cd-3f9256bcaa8e) --------- Co-authored-by: Elastic Machine <[email protected]>
Replace the existing
ConnectorNameAndDescription
component with separateConnectorName
andConnectorDescription
components for improved accessibility as pointed out in this issue #198001 . Now only the H1 wraps the Title and the Descriptions is out of it.Before:
After: