From fa1dd72980a1f73c7b682da9290338ad4c81cefe Mon Sep 17 00:00:00 2001 From: emyarod Date: Thu, 9 Nov 2023 12:10:56 -0600 Subject: [PATCH] fix(tabs): remove overflow button conditional rendering check Co-authored-by: Ariella Gilmore --- .../src/components/tabs/tabs.ts | 65 ++++++++++++------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/packages/carbon-web-components/src/components/tabs/tabs.ts b/packages/carbon-web-components/src/components/tabs/tabs.ts index 1c9b55bfcc1..9a532615a07 100644 --- a/packages/carbon-web-components/src/components/tabs/tabs.ts +++ b/packages/carbon-web-components/src/components/tabs/tabs.ts @@ -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() { 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() { + 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()}
@@ -458,18 +488,7 @@ export default class CDSTabs extends HostListenerMixin(CDSContentSwitcher) {
- - + ${this.renderNextButton()}