diff --git a/packages/carbon-web-components/src/components/tabs/tabs.ts b/packages/carbon-web-components/src/components/tabs/tabs.ts index 1c9b55bfcc1..18320f948a7 100644 --- a/packages/carbon-web-components/src/components/tabs/tabs.ts +++ b/packages/carbon-web-components/src/components/tabs/tabs.ts @@ -7,7 +7,7 @@ * LICENSE file in the root directory of this source tree. */ -import { html } from 'lit'; +import { TemplateResult, html } from 'lit'; import { property, state, query } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { prefix } from '../../globals/settings'; @@ -310,7 +310,7 @@ export default class CDSTabs extends HostListenerMixin(CDSContentSwitcher) { }; /** - * Cleans-up and creats the intersection observer for the scrolling container. + * Cleans-up and creates the intersection observer for the scrolling container. * * @param [options] The options. * @param [options.create] `true` to create the new intersection observer. @@ -411,14 +411,13 @@ export default class CDSTabs extends HostListenerMixin(CDSContentSwitcher) { } } - render() { + /** + * Render the previous button if tablist is wider than container. + */ + protected renderPreviousButton(): TemplateResult | null { const { _isIntersectionLeftTrackerInContent: isIntersectionLeftTrackerInContent, - _isIntersectionRightTrackerInContent: isIntersectionRightTrackerInContent, - _assistiveStatusText: assistiveStatusText, - _handleSlotchange: handleSlotchange, } = this; - const previousButtonClasses = classMap({ [`${prefix}--tab--overflow-nav-button`]: true, [`${prefix}--tabs__nav-caret-left`]: true, @@ -426,6 +425,28 @@ export default class CDSTabs extends HostListenerMixin(CDSContentSwitcher) { [`${prefix}--tab--overflow-nav-button--hidden`]: isIntersectionLeftTrackerInContent, }); + return html` + + `; + } + + /** + * Render the next button if tablist is wider than container. + */ + protected renderNextButton(): TemplateResult | null { + const { + _isIntersectionRightTrackerInContent: isIntersectionRightTrackerInContent, + } = this; const nextButtonClasses = classMap({ [`${prefix}--tab--overflow-nav-button`]: true, [`${prefix}--tabs__nav-caret-right`]: true, @@ -433,20 +454,29 @@ export default class CDSTabs extends HostListenerMixin(CDSContentSwitcher) { [`${prefix}--tab--overflow-nav-button--hidden`]: isIntersectionRightTrackerInContent, }); - return html` + `; + } + + render() { + const { + _assistiveStatusText: assistiveStatusText, + _handleSlotchange: handleSlotchange, + } = this; + return html` + ${this.renderPreviousButton()}