Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ const DemoFinallyNode: React.FunctionComponent<DemoFinallyNodeProps> = ({ ...pro
return (
<Layer id={detailsLevel !== ScaleDetailsLevel.high && hover ? TOP_LAYER : DEFAULT_LAYER}>
<g ref={hoverRef}>
<FinallyNode scaleNode={hover && detailsLevel !== ScaleDetailsLevel.high} hideDetailsAtMedium {...props} />
<FinallyNode
tabIndex={props.element.getData()?.tabIndex}
scaleNode={hover && detailsLevel !== ScaleDetailsLevel.high}
hideDetailsAtMedium
{...props}
/>
</g>
</Layer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@ import {
WithDragNodeProps,
WithSelectionProps
} from '@patternfly/react-topology';
import { DEFAULT_TASK_HEIGHT, DEFAULT_TASK_WIDTH } from './useDemoPipelineNodes';

type DemoPipelinesGroupProps = {
element: GraphElement;
} & WithContextMenuProps &
WithDragNodeProps &
WithSelectionProps;

const DemoPipelinesGroup: React.FunctionComponent<DemoPipelinesGroupProps> = ({ element }) => {
const DemoPipelinesGroup: React.FunctionComponent<DemoPipelinesGroupProps> = ({ element, ...rest }) => {
const data = element.getData();

return (
<DefaultTaskGroup
element={element}
collapsible={false}
tabIndex={data?.tabIndex}
collapsible
collapsedWidth={DEFAULT_TASK_WIDTH}
collapsedHeight={DEFAULT_TASK_HEIGHT}
labelPosition={LabelPosition.top}
showLabelOnHover
hideDetailsAtMedium
badge={data?.badge}
{...rest}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const DemoTaskNode: React.FunctionComponent<DemoTaskNodeProps> = ({
<g ref={hoverRef}>
<TaskNode
element={element}
labelTooltipTrigger="mouseenter"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context menus are not able to be opened or focused via keyboard.

If you add an actionIconAriaLabel to these TaskNodes, i think that should give it a tabindex because of the logic on LabelActionIcon.tsx:507

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will, this is for the Set tab indices option. When that is off, no data.tabIndex will be set.

onContextMenu={pipelineOptions.showContextMenus ? onContextMenu : undefined}
contextMenuOpen={contextMenuOpen}
scaleNode={(hover || contextMenuOpen) && detailsLevel !== ScaleDetailsLevel.high}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export const PipelineTasks: React.FC = observer(() => {
const pipelineNodes = useDemoPipelineNodes(
pipelineOptions.showContextMenus,
pipelineOptions.showBadges,
pipelineOptions.showIcons
pipelineOptions.showIcons,
'',
false
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ComponentFactory,
ModelKind,
SpacerNode,
DefaultTaskGroup,
DEFAULT_TASK_NODE_TYPE,
DEFAULT_SPACER_NODE_TYPE,
DEFAULT_EDGE_TYPE,
Expand Down Expand Up @@ -51,13 +50,13 @@ const pipelineComponentFactory: ComponentFactory = (
}
switch (type) {
case DEFAULT_TASK_NODE_TYPE:
return withContextMenu(() => defaultMenu)(withSelection()(DemoTaskNode));
return withContextMenu(() => defaultMenu)(withSelection({ raiseOnSelect: false })(DemoTaskNode));
case DEFAULT_FINALLY_NODE_TYPE:
return withContextMenu(() => defaultMenu)(withSelection()(DemoFinallyNode));
return withContextMenu(() => defaultMenu)(withSelection({ raiseOnSelect: false })(DemoFinallyNode));
case 'task-group':
return withSelection()(DemoPipelinesGroup);
return withSelection({ raiseOnSelect: false })(DemoPipelinesGroup);
case 'finally-group':
return DefaultTaskGroup;
return withSelection({ raiseOnSelect: false })(DemoPipelinesGroup);
case DEFAULT_SPACER_NODE_TYPE:
return SpacerNode;
case SPACER_EDGE_TYPE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ export const useDemoPipelineNodes = (
i++;
}

const parallelTasks: PipelineNodeModel[] = [];
if (layout) {
const parallelTasks: PipelineNodeModel[] = [];

for (let i = 0; i < PARALLEL_TASKS_COUNT; i++) {
const parallelTask: PipelineNodeModel = {
id: `parallelTasks-${i}`,
Expand Down Expand Up @@ -144,19 +143,6 @@ export const useDemoPipelineNodes = (
}
}
tasks.push(...parallelTasks);

if (showGroups) {
tasks.push({
id: `group-parallels`,
type: 'task-group',
children: parallelTasks.map((t) => t.id),
group: true,
label: 'Parallel tasks',
data: {
badge: 'Label'
}
});
}
}

const finallyNodes = [];
Expand All @@ -167,7 +153,9 @@ export const useDemoPipelineNodes = (
label: `Finally task ${i}`,
width: FINALLY_TASK_WIDTH,
height: DEFAULT_TASK_HEIGHT,
style: { paddingLeft: DEFAULT_WHEN_SIZE + DEFAULT_WHEN_OFFSET }
style: {
padding: [NODE_PADDING_VERTICAL, NODE_PADDING_HORIZONTAL]
}
};

if (!layout) {
Expand All @@ -181,6 +169,7 @@ export const useDemoPipelineNodes = (
const finallyGroup = {
id: 'finally-group',
type: 'finally-group',
label: 'Finally group',
children: finallyNodes.map((n) => n.id),
group: true
};
Expand All @@ -206,6 +195,19 @@ export const useDemoPipelineNodes = (
}, [] as PipelineNodeModel[]);

tasks.push(...taskGroups);

if (parallelTasks.length > 0) {
tasks.push({
id: `group-parallels`,
type: 'task-group',
children: parallelTasks.map((t) => t.id),
group: true,
label: 'Parallel tasks',
data: {
badge: 'Label'
}
});
}
}

const iconTask1: PipelineNodeModel = {
Expand All @@ -232,7 +234,7 @@ export const useDemoPipelineNodes = (
};

if (!layout) {
const row = Math.ceil((TASK_STATUSES.length + 1) / STATUS_PER_ROW) - 1;
const row = Math.ceil((TASK_STATUSES.length + 1) / STATUS_PER_ROW);
const columnWidth = COLUMN_WIDTH + (showIcons ? 15 : 0) + (showBadges ? 32 : 0) + (showContextMenu ? 20 : 0);
iconTask1.x = (showIcons ? 28 : 0) + columnWidth;
iconTask1.y = GRAPH_MARGIN_TOP + row * ROW_HEIGHT;
Expand Down Expand Up @@ -261,7 +263,7 @@ export const useDemoPipelineNodes = (
};

if (!layout) {
const row = Math.ceil((TASK_STATUSES.length + 1) / STATUS_PER_ROW) - 1;
const row = Math.ceil((TASK_STATUSES.length + 1) / STATUS_PER_ROW);
const columnWidth = COLUMN_WIDTH + (showIcons ? 15 : 0) + (showBadges ? 32 : 0) + (showContextMenu ? 20 : 0);
iconTask2.x = (showIcons ? 28 : 0) + 2 * columnWidth;
iconTask2.y = GRAPH_MARGIN_TOP + row * ROW_HEIGHT;
Expand Down Expand Up @@ -290,7 +292,7 @@ export const useDemoPipelineNodes = (
};

if (!layout) {
const row = Math.ceil((TASK_STATUSES.length + 1) / STATUS_PER_ROW) - 1;
const row = Math.ceil((TASK_STATUSES.length + 1) / STATUS_PER_ROW);
const columnWidth = COLUMN_WIDTH + (showIcons ? 15 : 0) + (showBadges ? 32 : 0) + (showContextMenu ? 20 : 0);
iconTask3.x = (showIcons ? 28 : 0) + 3 * columnWidth;
iconTask3.y = GRAPH_MARGIN_TOP + row * ROW_HEIGHT;
Expand Down
15 changes: 15 additions & 0 deletions packages/module/patternfly-docs/content/examples/Accessibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
id: Accessibility
section: extensions
subsection: topology
sortValue: 999
---
Comment on lines +1 to +6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a followup if it isn't as straight forward to implement for an extension, but if this file is meant to be strictly accessibility for the "Pipelines" section of topology, would be nice to include it as a tab on the Pipelines page (similar to how each PF component has the "HTML", "React", ..., "Accessibility" tabs)

@jeff-phillips-18 jeff-phillips-18 Aug 25, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that but I'm not sure where we would document the accessibility features for non-pipeline layouts.

Once we have it for both, the information for both will likely not need to be split between layout types. We can have it all here in one section. But for now, we only support it for pipelines.


## Pipelines layout

By default, `<TaskNode>` and `<DefaultTaskGroup>` are included in the keyboard tab order (`tabIndex` is `0`). Tab order follows the order of items in the `model`. An expanded group receives focus before the nodes inside it. To set a custom tab order, pass `tabIndex` on `<TaskNode>` or `<DefaultTaskGroup>`.

When you select nodes and groups with `withSelection` or `useSelection`, `raiseOnSelect` defaults to `true`. That option moves the selected item to the end of its siblings, which also moves it in the tab order. Each later selection places that item after the one you selected before it. To keep tab order stable, pass `{ raiseOnSelect: false }` to `withSelection` or `useSelection`.

To stop screen readers from announcing truncated labels twice, set `labelTooltipTrigger` to `mouseenter` on `<TaskNode>`. The tooltip then opens on hover only, so the truncated label is not added to the keyboard tab order.

19 changes: 17 additions & 2 deletions packages/module/src/components/VisualizationSurface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { observer } from 'mobx-react';
import { debounce, getResizeObserver } from '@patternfly/react-core';
import { css } from '@patternfly/react-styles';
import styles from '../css/topology-components';
import { State } from '../types';
import { isNode, Node, State } from '../types';
import SVGDefsProvider from './defs/SVGDefsProvider';
import ElementWrapper from './ElementWrapper';
import Dimensions from '../geom/Dimensions';
import useVisualizationController from '../hooks/useVisualizationController';
import { findParentElement } from '../pipelines';

interface VisualizationSurfaceProps {
/** State to be passed to the controller */
Expand Down Expand Up @@ -73,7 +74,21 @@ const VisualizationSurface: FunctionComponent<VisualizationSurfaceProps> = ({ st
const graph = controller.getGraph();

return (
<div data-test-id="topology" className={css(styles.topologyVisualizationSurface)} ref={measureRef}>
<div
data-test-id="topology"
className={css(styles.topologyVisualizationSurface)}
ref={measureRef}
onFocus={(e) => {
const parentElement = findParentElement(controller, e.target);
if (parentElement) {
if (isNode(parentElement)) {
controller
.getGraph()
.panIntoView(parentElement as Node, { minimumVisible: parentElement.getDimensions().width / 2 });
}
}
}}
>
<svg className={css(styles.topologyVisualizationSurfaceSvg)} onContextMenu={stopEvent}>
<SVGDefsProvider>
<ElementWrapper element={graph} />
Expand Down
2 changes: 1 addition & 1 deletion packages/module/src/components/layers/LayersProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class LayersProvider extends Component<LayersProviderProps, State
return (
<LayersContext.Provider value={this.contextValue}>
{layerIds.map((id) => (
<g key={id} data-layer-id={id} ref={(r) => this.setDomLayers(r, id)}>
<g key={id} data-layer-id={id} ref={(r) => this.setDomLayers(r, id)} tabIndex={-1}>
{id === DEFAULT_LAYER && this.state[id] ? children : undefined}
</g>
))}
Expand Down
29 changes: 26 additions & 3 deletions packages/module/src/components/nodes/labels/LabelActionIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { forwardRef } from 'react';
import { forwardRef, useRef } from 'react';
import { useSize } from '../../../utils';
import { css } from '@patternfly/react-styles';
import styles from '../../../css/topology-components';
import { handleKeyboardSelection } from '../../../utils/accessibility-utils';

interface LabelActionIconProps {
className?: string;
icon: React.ReactElement;
'aria-label'?: string;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are defining aria-label as the prop name here, and adding it to the calling definition, but then immediately re-casting it as 'ariaLabel' below, can we just have it as ariaLabel here as well? Do we expect this component to be called like a normal html element where a user might pass in 'aria-label' as a prop and that's why we do it this way? I see it used a couple of times in this PR, made me curious

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, in the base PatternFly react repo, that's how we handle aria props (use kebab case, but later use camel case). Just for consistency probably better to keep it like this here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was just following PatternFly conventions.

tabIndex?: number;
onClick: (e: React.MouseEvent) => void;
iconOffsetX?: number;
iconOffsetY?: number;
Expand All @@ -17,8 +20,24 @@ interface LabelActionIconProps {
}

const LabelActionIcon = forwardRef<SVGRectElement, LabelActionIconProps>(
({ icon, onClick, className, x, y, paddingX, height, iconOffsetX = 0, iconOffsetY = 0 }, actionRef) => {
(
{
icon,
onClick,
'aria-label': ariaLabel,
tabIndex = 0,
className,
x,
y,
paddingX,
height,
iconOffsetX = 0,
iconOffsetY = 0
},
actionRef
) => {
const [iconSize, iconRef] = useSize([icon, paddingX]);
const clickRef = useRef(null);
const iconWidth = iconSize?.width ?? 0;
const iconHeight = iconSize?.height ?? 0;
const iconY = (height - iconHeight) / 2;
Expand All @@ -33,7 +52,7 @@ const LabelActionIcon = forwardRef<SVGRectElement, LabelActionIconProps>(
};

return (
<g className={classes} onClick={handleClick}>
<g className={classes} onClick={handleClick} ref={clickRef}>
{iconSize && (
<rect
ref={actionRef}
Expand All @@ -42,6 +61,10 @@ const LabelActionIcon = forwardRef<SVGRectElement, LabelActionIconProps>(
y={y}
width={iconWidth + paddingX * 2}
height={height}
tabIndex={ariaLabel ? tabIndex : undefined}
aria-label={ariaLabel}
onKeyDown={handleKeyboardSelection(clickRef)}
data-id="context-icon"
/>
)}
<g
Expand Down
6 changes: 6 additions & 0 deletions packages/module/src/components/nodes/labels/NodeLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export type NodeLabelProps = {
actionIcon?: React.ReactElement;
actionIconClassName?: string;
onActionIconClick?: (e: React.MouseEvent) => void;
actionIconAriaLabel?: string;
actionIconTabIndex?: number;
badge?: string;
badgeColor?: string;
badgeTextColor?: string;
Expand Down Expand Up @@ -82,6 +84,8 @@ const NodeLabel: React.FunctionComponent<NodeLabelProps> = ({
actionIcon,
actionIconClassName,
onActionIconClick,
actionIconAriaLabel,
actionIconTabIndex,
boxRef,
...other
}) => {
Expand Down Expand Up @@ -293,6 +297,8 @@ const NodeLabel: React.FunctionComponent<NodeLabelProps> = ({
icon={actionIcon}
className={actionIconClassName}
onClick={onActionIconClick}
aria-label={actionIconAriaLabel}
tabIndex={actionIconTabIndex}
/>
</>
)}
Expand Down
12 changes: 12 additions & 0 deletions packages/module/src/css/topology-components.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
:root {
--pf-topology-visualization-surface--BackgroundColor: transparent;

--pf-topology__focus--outline-color: var(--pf-t--global--focus-ring--color--default);
--pf-topology__focus--outline-style: solid;
--pf-topology__focus--outline-width: var(--pf-t--global--border--width--strong);
--pf-topology__focus--outline-offset: var(--pf-t--global--focus-ring--position--offset);

/* Create connector */
/* Remove --pf-topology-create-connector-color at a breaking change */
--pf-topology-create-connector-color: var(--pf-t--global--border--color--on-secondary);
Expand Down Expand Up @@ -578,6 +583,13 @@
stroke-width: var(--pf-topology__group__background--StrokeWidth);
}

.pf-topology__group__background:focus-visible {
outline-color: var(--pf-topology__focus--outline-color);
outline-style: var(--pf-topology__focus--outline-style);
outline-width: var(--pf-topology__focus--outline-width);
outline-offset: var(--pf-topology__focus--outline-offset);
}

.pf-topology__group.pf-m-alt-group .pf-topology__group__background {
--pf-topology__group__background--Fill: var(--pf-topology__group--m-alt-group--topology__group__background--Fill);
--pf-topology__group__background--Stroke: var(--pf-topology__group--m-alt-group--topology__group__background--Stroke);
Expand Down
Loading
Loading