File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
packages/docusaurus-theme-openapi-docs/src/theme/SchemaTabs Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,21 @@ function SchemaTabsComponent(props) {
147147 const [ showTabArrows , setShowTabArrows ] = useState ( false ) ;
148148
149149 useEffect ( ( ) => {
150- const tabOffsetWidth = tabItemListContainerRef . current . offsetWidth ;
151- const tabScrollWidth = tabItemListContainerRef . current . scrollWidth ;
150+ const resizeObserver = new ResizeObserver ( ( entries ) => {
151+ for ( let entry of entries ) {
152+ if ( entry . target . offsetWidth < entry . target . scrollWidth ) {
153+ setShowTabArrows ( true ) ;
154+ } else {
155+ setShowTabArrows ( false ) ;
156+ }
157+ }
158+ } ) ;
152159
153- if ( tabOffsetWidth < tabScrollWidth ) {
154- setShowTabArrows ( true ) ;
155- }
160+ resizeObserver . observe ( tabItemListContainerRef . current ) ;
161+
162+ return ( ) => {
163+ resizeObserver . disconnect ( ) ;
164+ } ;
156165 } , [ ] ) ;
157166
158167 const handleRightClick = ( ) => {
You can’t perform that action at this time.
0 commit comments