Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabs): adjust the watch execution order of tabs and activeIndex #1936

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Saber-Kurama
Copy link
Contributor

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Component style change
  • Typescript definition change
  • Documentation change
  • Coding style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Breaking change
  • Others

Background and context

Solution

How is the change tested?

Changelog

Component Changelog(CN) Changelog(EN) Related issues
tabs 调整 tabs 和 activeIndex 的 watch 执行顺序 adjust the watch execution order of tabs and activeIndex #1867

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others
    should be submitted to main branch)

Other information

activeKey={computedActiveKey.value}
activeIndex={activeIndex.value}
tabs={sortedTabs.value}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

仅修改 tabs 的顺序不能解决这个问题吧,这里不会影响 TabsNav 内部计算初始显示位置的时机

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原本是打算用 flush: 'sync' 或者immediate:true来确保tabs的watch比activeIndex的watch先执行,在用vite写的demo的时候发现切换顺序也能让tabs的watch先执行。不过webpack中却不是这样的。保证watch的顺序还是得用flush: 'sync' 或者immediate:true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不过虽然可以让tabs的watch先执行,但是在activeIndex中的watch获取wrapperLength.valuemaxOffset.value不正确的值

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activeIndex 中watch的nextTick我直接换成了setTimeout,也可以watch([tabs,activeIndex]判断tabs发生修改才用setTimeout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外就是直接设置activeIndex 为最后一项的时候,next按钮并未置灰 。offset.value值比maxOffset.value小了几像素

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants