Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 26, 2025

Scroll arrows in horizontally scrollable tabs don't hide when container width increases enough to fit all tabs.

Root Cause

useResize was called with navsContainerRef.value during setup, which is undefined before mount. The ResizeObserver never attached to the element, so container resizes weren't detected.

// Before - ResizeObserver never attached
useResize(debounce(getMaxScrollLeft), navsContainerRef.value);  // undefined during setup

Changes

  • Replace useResize with useResizeObserver hook
  • Pass the ref directly instead of its value
// After - ResizeObserver properly observes container
useResizeObserver(navsContainerRef, debounce(getMaxScrollLeft));

useResizeObserver accepts Ref<HTMLElement> and uses watch to attach the observer when the element becomes available. This pattern matches existing usage in tab-nav-bar.tsx and radio/group.tsx.

Original prompt

This section details on the original issue you should resolve

<issue_title>[TTabs] 可横向滚动的tabs组件,在宽度变的充裕时没有去掉滚动行为</issue_title>
<issue_description>

重现链接

https://codesandbox.io/p/sandbox/tdesign-vue-next-tabs-combination-demo-forked-ll8nl7?file=%2Fsrc%2Fdemo.vue%3A13%2C45-13%2C60

重现步骤

左右拖动中间的split line改变宽度,可复现操作
正常.png
缩小.png
放宽.png

期望结果

在宽度变的充裕时去掉滚动行为

实际结果

在宽度变的充裕时没有去掉滚动行为,滚动箭头还是存在

Environment Info
相关版本 1.17.7
框架版本 / 基础库版本 vue(3.5.26)
系统、浏览器 Chrome(143.0.7499.170)
Node版本 20.19.1

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Fix scroll arrows not disappearing when tabs container becomes wide enough.
Changed from useResize to useResizeObserver and pass the ref directly
instead of .value to ensure ResizeObserver is properly attached.

Co-authored-by: Wesley-0808 <[email protected]>
Copilot AI changed the title [WIP] Fix tabs component scrolling behavior when width increases fix(tabs): ResizeObserver not attached when using useResize with undefined ref Dec 26, 2025
Copilot AI requested a review from Wesley-0808 December 26, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TTabs] 可横向滚动的tabs组件,在宽度变的充裕时没有去掉滚动行为

2 participants