File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/react/src/components/Tabs Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,15 @@ export default class Tabs extends React.Component {
153153
154154 _handleWindowResize = this . handleScroll ;
155155
156+ /**
157+ * The debounced version of the `scroll` event handler.
158+ * @type {Function }
159+ * @private
160+ */
161+ _debouncedHandleScroll = null ;
162+
163+ _handleScroll = this . handleScroll ;
164+
156165 componentDidMount ( ) {
157166 if ( ! this . _debouncedHandleWindowResize ) {
158167 this . _debouncedHandleWindowResize = debounce (
@@ -164,6 +173,10 @@ export default class Tabs extends React.Component {
164173 this . _handleWindowResize ( ) ;
165174 window . addEventListener ( 'resize' , this . _debouncedHandleWindowResize ) ;
166175
176+ if ( ! this . _debouncedHandleScroll ) {
177+ this . _debouncedHandleScroll = debounce ( this . _handleScroll , 125 ) ;
178+ }
179+
167180 // scroll selected tab into view on mount
168181 const {
169182 clientWidth : tablistClientWidth ,
@@ -516,7 +529,7 @@ export default class Tabs extends React.Component {
516529 tabIndex = { - 1 }
517530 className = { classes . tablist }
518531 ref = { this . tablist }
519- onScroll = { this . handleScroll } >
532+ onScroll = { this . _debouncedHandleScroll } >
520533 { tabsWithProps }
521534 </ ul >
522535 { ! rightOverflowNavButtonHidden && (
You can’t perform that action at this time.
0 commit comments