Skip to content
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

[a11y] Miscellaneous updates #5574

Merged
merged 5 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## [`main`](https://github.com/elastic/eui/tree/main)

- Updated `EuiDataGrid`s with scrolling content to always have a border around the grid body and any scrollbars ([#5563](https://github.com/elastic/eui/pull/5563))
- Added referenceable `id` for the generated label in `EuiFormRow` ([#5574](https://github.com/elastic/eui/pull/5574))
- Addeed optional attribute configurations in `EuiPopover` to aid screen reader announcements ([#5574](https://github.com/elastic/eui/pull/5574))
- Added `ref` passthroughs to `EuiIputPopover` subcomponents ([#5574](https://github.com/elastic/eui/pull/5574))

**Bug fixes**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ exports[`EuiDescribedFormGroup ties together parts for accessibility 1`] = `
aria-invalid={true}
className="euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
isFocused={false}
isInvalid={true}
type="label"
Expand All @@ -685,6 +686,7 @@ exports[`EuiDescribedFormGroup ties together parts for accessibility 1`] = `
aria-invalid={true}
className="euiFormLabel euiFormRow__label euiFormLabel-isInvalid"
htmlFor="generated-id"
id="generated-id-label"
>
Label
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ exports[`EuiFormRow behavior onBlur is called in child 1`] = `
<EuiFormLabel
className="euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
isFocused={false}
type="label"
>
<label
className="euiFormLabel euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
>
<span>
Label
Expand Down Expand Up @@ -74,12 +76,14 @@ exports[`EuiFormRow behavior onBlur works in parent even if not in child 1`] = `
<EuiFormLabel
className="euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
isFocused={false}
type="label"
>
<label
className="euiFormLabel euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
>
<span>
Label
Expand Down Expand Up @@ -124,12 +128,14 @@ exports[`EuiFormRow behavior onFocus is called in child 1`] = `
<EuiFormLabel
className="euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
isFocused={true}
type="label"
>
<label
className="euiFormLabel euiFormRow__label euiFormLabel-isFocused"
htmlFor="generated-id"
id="generated-id-label"
>
<span>
Label
Expand Down Expand Up @@ -174,12 +180,14 @@ exports[`EuiFormRow behavior onFocus works in parent even if not in child 1`] =
<EuiFormLabel
className="euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
isFocused={true}
type="label"
>
<label
className="euiFormLabel euiFormRow__label euiFormLabel-isFocused"
htmlFor="generated-id"
id="generated-id-label"
>
<span>
Label
Expand Down Expand Up @@ -521,6 +529,7 @@ exports[`EuiFormRow props isInvalid is rendered 1`] = `
aria-invalid="true"
class="euiFormLabel euiFormRow__label euiFormLabel-isInvalid"
for="generated-id"
id="generated-id-label"
>
label
</label>
Expand All @@ -546,6 +555,7 @@ exports[`EuiFormRow props label append is rendered 1`] = `
<EuiFormLabel
className="euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
isFocused={false}
type="label"
>
Expand Down Expand Up @@ -577,6 +587,7 @@ exports[`EuiFormRow props label is rendered 1`] = `
<EuiFormLabel
className="euiFormRow__label"
htmlFor="generated-id"
id="generated-id-label"
isFocused={false}
type="label"
>
Expand Down Expand Up @@ -605,6 +616,7 @@ exports[`EuiFormRow props label renders as a legend and subsquently a fieldset w
>
<EuiFormLabel
className="euiFormRow__label"
id="generated-id-label"
type="legend"
>
label
Expand Down
2 changes: 2 additions & 0 deletions src/components/form/form_row/form_row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export class EuiFormRow extends Component<EuiFormRowProps, EuiFormRowState> {

let optionalLabel;
const isLegend = label && labelType === 'legend' ? true : false;
const labelId = `${id}-label`;

if (label || labelAppend) {
let labelProps = {};
Expand All @@ -241,6 +242,7 @@ export class EuiFormRow extends Component<EuiFormRowProps, EuiFormRowState> {
isInvalid={isInvalid}
isDisabled={isDisabled}
aria-invalid={isInvalid}
id={labelId}
{...labelProps}
>
{label}
Expand Down
8 changes: 5 additions & 3 deletions src/components/popover/input_popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { CommonProps } from '../common';
import { EuiFocusTrap } from '../focus_trap';
import { EuiPopover, EuiPopoverProps } from './popover';
import { EuiResizeObserver } from '../observer/resize_observer';
import { cascadingMenuKeys } from '../../services';
import { cascadingMenuKeys, useCombinedRefs } from '../../services';

export interface _EuiInputPopoverProps
extends Omit<EuiPopoverProps, 'button' | 'buttonRef'> {
Expand All @@ -42,14 +42,16 @@ export const EuiInputPopover: FunctionComponent<EuiInputPopoverProps> = ({
input,
fullWidth = false,
onPanelResize,
inputRef: _inputRef,
panelRef: _panelRef,
...props
}) => {
const [inputEl, setInputEl] = useState<HTMLElement | null>(null);
const [inputElWidth, setInputElWidth] = useState<number>();
const [panelEl, setPanelEl] = useState<HTMLElement | null>(null);

const inputRef = (node: HTMLElement | null) => setInputEl(node);
const panelRef = (node: HTMLElement | null) => setPanelEl(node);
const inputRef = useCombinedRefs([setInputEl, _inputRef]);
const panelRef = useCombinedRefs([setPanelEl, _panelRef]);

const setPanelWidth = useCallback(
(width?: number) => {
Expand Down
13 changes: 10 additions & 3 deletions src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,14 @@ export class EuiPopover extends Component<Props, State> {
let ariaDescribedby;
let ariaLive: HTMLAttributes<any>['aria-live'];

if (ownFocus) {
const panelAriaModal = panelProps?.hasOwnProperty('aria-modal')
? panelProps['aria-modal']
: 'true';
const panelRole = panelProps?.hasOwnProperty('role')
? panelProps.role
: 'dialog';

if (ownFocus || panelAriaModal !== 'true') {
tabIndex = tabIndexProp ?? 0;
ariaLive = 'off';

Expand Down Expand Up @@ -784,10 +791,10 @@ export class EuiPopover extends Component<Props, State> {
paddingSize={panelPaddingSize}
tabIndex={tabIndex}
aria-live={ariaLive}
role="dialog"
role={panelRole}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
aria-modal="true"
aria-modal={panelAriaModal}
aria-describedby={ariaDescribedby}
style={{
...this.state.popoverStyles,
Expand Down
10 changes: 1 addition & 9 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,7 @@ export {

export { EuiWindowEvent } from './window_event';

export {
useCombinedRefs,
useForceRender,
useUpdateEffect,
useDependentState,
useIsWithinBreakpoints,
useMouseMove,
isMouseEvent,
} from './hooks';
export * from './hooks';

export { throttle } from './throttle';

Expand Down