Skip to content

Commit 532ebc8

Browse files
emyarodjoshblack
authored andcommitted
fix(tabs): truncate container tab header text with ellipses (#5035)
1 parent 3919125 commit 532ebc8

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

packages/components/src/components/tabs/_tabs.scss

+12-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
display: flex;
4343
align-items: center;
4444
justify-content: space-between;
45-
padding: 0 $spacing-05;
45+
padding: 0 $spacing-09 0 $spacing-05;
4646
height: rem(40px);
4747
cursor: pointer;
4848
color: $text-01;
@@ -60,8 +60,8 @@
6060
}
6161

6262
.#{$prefix}--tabs-trigger svg {
63-
width: rem(12px);
64-
height: rem(7px);
63+
position: absolute;
64+
right: $spacing-05;
6565
fill: $ui-05;
6666
transition: transform $duration--fast-01 motion(standard, productive);
6767
}
@@ -90,6 +90,9 @@
9090
padding-top: 2px;
9191
color: $text-01;
9292
font-weight: 400;
93+
white-space: nowrap;
94+
overflow: hidden;
95+
text-overflow: ellipsis;
9396
}
9497

9598
.#{$prefix}--tabs-trigger-text:hover {
@@ -274,6 +277,9 @@
274277
background-color: $ui-01;
275278

276279
.#{$prefix}--tabs__nav-link {
280+
line-height: calc(
281+
#{rem(48px)} - (#{$spacing-03} * 2)
282+
); // height - vertical padding
277283
// Draws the border without affecting the inner-content
278284
box-shadow: inset 0 2px 0 0 $interactive-04;
279285
border-bottom: none;
@@ -333,9 +339,10 @@
333339

334340
.#{$prefix}--tabs--container a.#{$prefix}--tabs__nav-link {
335341
@include carbon--breakpoint(md) {
336-
display: flex;
337-
align-items: center;
338342
height: rem(48px);
343+
line-height: calc(
344+
#{rem(48px)} - (#{$spacing-03} * 2)
345+
); // height - vertical padding
339346
border-bottom: none;
340347
}
341348
}

packages/components/src/components/tabs/tabs.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div data-tabs class="{{@root.prefix}}--tabs{{#if container}} {{@root.prefix}}--tabs--container{{/if}}">
99
<div class="{{@root.prefix}}--tabs-trigger" tabindex="0">
1010
<a href="javascript:void(0)" class="{{@root.prefix}}--tabs-trigger-text" tabindex="-1"></a>
11-
{{ carbon-icon 'ChevronDownGlyph' }}
11+
{{ carbon-icon 'ChevronDown16' }}
1212
</div>
1313
<ul class="{{@root.prefix}}--tabs__nav {{@root.prefix}}--tabs__nav--hidden" role="tablist">
1414
{{#each items}}

packages/react/src/components/Tabs/Tabs-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import React from 'react';
9-
import { ChevronDownGlyph } from '@carbon/icons-react';
9+
import { ChevronDown16 } from '@carbon/icons-react';
1010
import { settings } from 'carbon-components';
1111
import { shallow, mount } from 'enzyme';
1212
import Tabs from '../Tabs';
@@ -102,7 +102,7 @@ describe('Tabs', () => {
102102
});
103103

104104
it('renders <Icon>', () => {
105-
expect(trigger.find(ChevronDownGlyph).length).toBe(1);
105+
expect(trigger.find(ChevronDown16).length).toBe(1);
106106
});
107107
});
108108

packages/react/src/components/Tabs/Tabs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import PropTypes from 'prop-types';
99
import React from 'react';
1010
import classNames from 'classnames';
11-
import { ChevronDownGlyph } from '@carbon/icons-react';
11+
import { ChevronDown16 } from '@carbon/icons-react';
1212
import { settings } from 'carbon-components';
1313
import { keys, match, matches } from '../../internal/keyboard';
1414

@@ -294,9 +294,9 @@ export default class Tabs extends React.Component {
294294
onClick={this.handleDropdownClick}>
295295
{selectedLabel}
296296
</a>
297-
<ChevronDownGlyph aria-hidden="true">
297+
<ChevronDown16 aria-hidden="true">
298298
{iconDescription && <title>{iconDescription}</title>}
299-
</ChevronDownGlyph>
299+
</ChevronDown16>
300300
</div>
301301
<ul role="tablist" className={classes.tablist}>
302302
{tabsWithProps}

0 commit comments

Comments
 (0)