react-component / react-component/tabs

SwipeableTabBarNode 中 didUpdate 时 setCache 导致 cache 里面的 totalDelta 会消失。

Open
#136 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
572
Forks
241
Avg merge
4d 18h
Merged PRs (30d)
4

Description

https://github.com/react-component/tabs/blob/master/src/SwipeableTabBarNode.js#L34

原因是在 didUpdate 时,只有 activeKey 发生变化时才会 setSwipePositionByKey,而 totalDelta 是在setSwipePositionByKey 里面调用的 setSwipePosition 里设置的。而 setCache,不是采用 merge 的形式,而是直接覆盖了整个 cache,导致 totalDelta 会消失。

这直接导致 https://github.com/react-component/tabs/blob/master/src/SwipeableTabBarNode.js#L48 _nextDelta 变成了 NaN ,于是无法滑动了。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect src/SwipeableTabBarNode.js at the didUpdate logic around line 34 and the _nextDelta calculation around line 48. Reproduce the swipe failure, then verify that updating the cache preserves totalDelta so _nextDelta remains usable and swiping works again.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.