From 2ae6a5c08e34d83f714a1e945987467037836e4b Mon Sep 17 00:00:00 2001 From: Alla Doroshkevych Date: Fri, 16 Feb 2024 10:48:21 -0500 Subject: [PATCH] resize handle id description added --- .../src/subcomponents/ColumnHeaderCell.jsx | 13 +++++++------ .../src/subcomponents/ColumnResizeHandle.jsx | 6 +++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/terra-table/src/subcomponents/ColumnHeaderCell.jsx b/packages/terra-table/src/subcomponents/ColumnHeaderCell.jsx index 37d4eb77553..ee60c521e4c 100644 --- a/packages/terra-table/src/subcomponents/ColumnHeaderCell.jsx +++ b/packages/terra-table/src/subcomponents/ColumnHeaderCell.jsx @@ -328,8 +328,8 @@ const ColumnHeaderCell = (props) => { headerDescription += sortDescription ? `, ${sortDescription}` : ''; // set focus to the action button - const distributeFocusWithinActionCell = () => { - columnHeaderCellRef?.current?.childNodes[0].focus(); + const focusActionCell = () => { + columnHeaderCellRef?.current?.childNodes[0]?.focus(); }; const isPinnedColumn = columnIndex < columnContext.pinnedColumnOffsets.length; @@ -371,6 +371,8 @@ const ColumnHeaderCell = (props) => { ); } + const resizeHandleId = `${tableId}-${columnId}-resizeHandle`; + return ( /* eslint-disable react/forbid-dom-props */ { tabIndex={isGridContext && !hasButtonElement ? -1 : undefined} role={!isActionCell ? 'columnheader' : undefined} scope={!isActionCell ? 'col' : undefined} - // aria-owns={!isActionCell ? `${tableId}-${columnId}-actionCell` : undefined} // This way header owns action - aria-owns={isActionCell ? `${tableId}-${columnId}-resizeHandle` : undefined} // Action owns handle + aria-owns={isActionCell ? resizeHandleId : undefined} // Action Cell has to own a corresponding resize handle to avoid a double announcement on handle focus when it comes from action cell title={!isActionCell ? displayName : action?.label} onMouseDown={isSelectable && onColumnSelect ? handleMouseDown : undefined} onKeyDown={(isSelectable || isResizable) ? handleKeyDown : undefined} // eslint-disable-next-line react/forbid-component-props style={{ width: `${width}px`, height: isActionCell ? 'auto' : headerHeight, left: cellLeftEdge }} - onFocus={isActionCell ? distributeFocusWithinActionCell : undefined} + onFocus={isActionCell ? focusActionCell : undefined} > {cellContent} { isResizable && !isActionCell && (