Skip to content

Commit

Permalink
fix(TableHeader): add flex wrapper for sortable headers
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Jul 1, 2020
1 parent 0f2b80e commit a523eb7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
opacity: 1;
}

// -------------------------------------
// Th > Button > Span (span required for flex bugs in Safari)
// -------------------------------------
.#{$prefix}--data-table--sort th .#{$prefix}--table-sort__flex {
display: flex;
align-items: center;
height: 100%;
}

// -------------------------------------
//Th > Button > Svg (Sort Icons)
// -------------------------------------
Expand Down Expand Up @@ -123,6 +132,13 @@
.#{$prefix}--data-table--tall.#{$prefix}--data-table--sort
th
.#{$prefix}--table-sort {
display: inline-block;
height: rem(64px);
}

.#{$prefix}--data-table--tall.#{$prefix}--data-table--sort
th
.#{$prefix}--table-sort__flex {
align-items: flex-start;
}

Expand Down
40 changes: 21 additions & 19 deletions packages/react/src/components/DataTable/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,27 @@ const TableHeader = React.forwardRef(function TableHeader(
ref={ref}
scope={scope}>
<button className={className} onClick={onClick} {...rest}>
<div className={`${prefix}--table-header-label`}>{children}</div>
<Arrow
className={`${prefix}--table-sort__icon`}
aria-label={t('carbon.table.header.icon.description', {
header: children,
sortDirection,
isSortHeader,
sortStates,
})}
/>
<Arrows
className={`${prefix}--table-sort__icon-unsorted`}
aria-label={t('carbon.table.header.icon.description', {
header: children,
sortDirection,
isSortHeader,
sortStates,
})}
/>
<span className={`${prefix}--table-sort__flex`}>
<div className={`${prefix}--table-header-label`}>{children}</div>
<Arrow
className={`${prefix}--table-sort__icon`}
aria-label={t('carbon.table.header.icon.description', {
header: children,
sortDirection,
isSortHeader,
sortStates,
})}
/>
<Arrows
className={`${prefix}--table-sort__icon-unsorted`}
aria-label={t('carbon.table.header.icon.description', {
header: children,
sortDirection,
isSortHeader,
sortStates,
})}
/>
</span>
</button>
</th>
);
Expand Down

0 comments on commit a523eb7

Please sign in to comment.