Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
empty action cell text added
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroshk committed Feb 14, 2024
1 parent 6ba44dd commit 91d9d1e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
67 changes: 42 additions & 25 deletions packages/terra-table/src/subcomponents/ColumnHeaderCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,47 @@ const ColumnHeaderCell = (props) => {
};

const isPinnedColumn = columnIndex < columnContext.pinnedColumnOffsets.length;
const CellTag = !isActionCell ? 'th' : 'td';

// Create cell content
let cellContent;
if (isActionCell) {
if (action) {
cellContent = (
<Button
variant="de-emphasis"
ref={columnHeaderCellRef}
isCompact
onClick={action.onClick}
onKeyDown={(event) => handleKeyDown(event, action?.onClick)}
text={action.label}
/>
);
} else {
cellContent = (
<span aria-hidden className={cx('display-text', 'hidden')}>
{intl.formatMessage({ id: 'Terra.table.noAction' })}
</span>
);
}
} else {
cellContent = (
<div
className={cx('header-container')}
{...hasButtonElement && { ref: columnHeaderCellRef, role: 'button' }}
tabIndex={buttonTabIndex}
>
{errorIcon}
<span aria-hidden className={cx('display-text', { hidden: !isDisplayVisible })}>{displayName}</span>
{sortIndicatorIcon}
<VisuallyHiddenText text={headerDescription} />
</div>
);
}

return (
/* eslint-disable react/forbid-dom-props */
<th
<CellTag
ref={!hasButtonElement ? columnHeaderCellRef : undefined}
id={`${tableId}-${id}`}
key={id}
Expand All @@ -356,31 +393,11 @@ const ColumnHeaderCell = (props) => {
title={displayName}
onMouseDown={isSelectable && onColumnSelect ? handleMouseDown : undefined}
onKeyDown={(isSelectable || isResizable) ? handleKeyDown : undefined}
style={{ width: `${width}px`, height: isActionCell ? 'auto' : headerHeight, left: cellLeftEdge }} // eslint-disable-line react/forbid-dom-props
// eslint-disable-next-line react/forbid-component-props
style={{ width: `${width}px`, height: isActionCell ? 'auto' : headerHeight, left: cellLeftEdge }}
onFocus={isActionCell ? distributeFocusWithinActionCell : undefined}
>
{isActionCell && action
? (
<Button
variant="de-emphasis"
ref={columnHeaderCellRef}
isCompact
onClick={action.onClick}
onKeyDown={(event) => handleKeyDown(event, action?.onClick)}
text={action.label}
/>
) : (
<div
className={cx('header-container')}
{...hasButtonElement && { ref: columnHeaderCellRef, role: 'button' }}
tabIndex={buttonTabIndex}
>
{errorIcon}
<span aria-hidden className={cx('display-text', { hidden: !isDisplayVisible })}>{displayName}</span>
{sortIndicatorIcon}
<VisuallyHiddenText text={headerDescription} />
</div>
)}
{cellContent}
{ isResizable && !isActionCell && (
<ColumnResizeHandle
columnIndex={columnIndex}
Expand All @@ -398,7 +415,7 @@ const ColumnHeaderCell = (props) => {
onResizeHandleChange={onResizeHandleChange}
/>
)}
</th>
</CellTag>
);
};

Expand Down
1 change: 1 addition & 0 deletions packages/terra-table/translations/en-GB.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Terra.table.blank": "Blank",
"Terra.table.noAction": "No column action",
"Terra.table.maskedCell": "Masked data",
"Terra.table.cell-focus-trapped": "Focus contained in cell. Press Escape to resume grid navigation.",
"Terra.table.cell-interactable": "Cell contains interactable elements. Press Enter to move focus inside the cell.",
Expand Down
1 change: 1 addition & 0 deletions packages/terra-table/translations/en-US.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Terra.table.blank": "Blank",
"Terra.table.noAction": "No column action",
"Terra.table.maskedCell": "Masked data",
"Terra.table.cell-focus-trapped": "Focus contained in cell. Press Escape to resume table navigation.",
"Terra.table.cell-interactable": "Cell contains interactable elements. Press Enter to move focus inside the cell.",
Expand Down
1 change: 1 addition & 0 deletions packages/terra-table/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Terra.table.blank": "Blank",
"Terra.table.noAction": "No column action",
"Terra.table.maskedCell": "Masked data",
"Terra.table.cell-focus-trapped": "Focus contained in cell. Press Escape to resume table navigation.",
"Terra.table.cell-interactable": "Cell contains interactable elements. Press Enter to move focus inside the cell.",
Expand Down

0 comments on commit 91d9d1e

Please sign in to comment.