Skip to content

Conversation

wufeng87
Copy link

有使用fixedColumns时才执行event.preventDefault等逻辑。

@vercel
Copy link

vercel bot commented Apr 15, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/table/43acu0ndq
✅ Preview: https://table-git-fork-wufeng87-6x.react-component.now.sh

@wufeng87
Copy link
Author

有个问题,我能有办法基于rc-table@6.7.0修改吗?我们项目刚好用的这个版本的rc-table

@wufeng87
Copy link
Author

@afc163 麻烦review下,谢谢。

@zombieJ
Copy link
Member

zombieJ commented Apr 17, 2020

在下面的 3 个 if 里加 event.preventDefault() 吧,直接在条件里加,最后一个 if 就到不了了:

table/src/Table.tsx

Lines 434 to 436 in 303b9b6

if (bodyTable && target !== bodyTable) {
bodyTable.scrollTop = scrollTop;
}

@wufeng87
Copy link
Author

wufeng87 commented Apr 20, 2020

@zombieJ 没preventDefault,最后一个if里的代码也没必要执行吧?

@zombieJ
Copy link
Member

zombieJ commented Apr 20, 2020

v3 版本的 Table 是多个 Table 模拟的,最后一个 if 是指在其他的 Table 里滚动时,同步一下 bodyTable。

@wufeng87
Copy link
Author

wufeng87 commented Apr 21, 2020

v3 版本的 Table 是多个 Table 模拟的,最后一个 if 是指在其他的 Table 里滚动时,同步一下 bodyTable。

@zombieJ 我试了下,这样改还有个问题。在scrollY这个demo里,给单元格加个rc-select组件,如果第三个if里的代码也执行,那么滚动select的滚动条时,select滚动条和talbebody的滚动条会同时滚动。
是需要给event.target再加个限定判断,以避免这个问题吗?

@zombieJ
Copy link
Member

zombieJ commented Apr 21, 2020

嗯,看起来是的。需要判断一下是否是当前的 Table 中的一个来做滚动。

@wufeng87
Copy link
Author

在下面的 3 个 if 里加 event.preventDefault() 吧,直接在条件里加,最后一个 if 就到不了了:

table/src/Table.tsx

Lines 434 to 436 in 303b9b6

if (bodyTable && target !== bodyTable) {
bodyTable.scrollTop = scrollTop;
}

@zombieJ 这个感觉涉及到的场景有点复杂了,是这样的吗?在这个逻辑前加一个判断,如果event.target不是tableBody的子dom,则return退出,也不要调用preventDefault和改body.scrollTop

@zombieJ
Copy link
Member

zombieJ commented Apr 21, 2020

这样吧,分步骤来。先搞这个 preventDefault,然后在去处理非 scroll target 的问题。免得一直合不了。

@codecov
Copy link

codecov bot commented Apr 22, 2020

Codecov Report

Merging #456 into 6.x will decrease coverage by 0.21%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              6.x     #456      +/-   ##
==========================================
- Coverage   89.49%   89.28%   -0.22%     
==========================================
  Files          16       16              
  Lines         838      840       +2     
  Branches      245      245              
==========================================
  Hits          750      750              
- Misses         88       90       +2     
Impacted Files Coverage Δ
src/Table.tsx 83.62% <0.00%> (-0.75%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7d53b6...97f4039. Read the comment docs.

@wufeng87
Copy link
Author

wufeng87 commented Apr 22, 2020

@zombieJ push了,第二次commit,我本地看着没这么大改动的(-3+4)。为啥到github这,变成全删全增了。。麻烦您帮忙看看了。

@wufeng87
Copy link
Author

@zombieJ 勾选下这个就正常了
image

@zombieJ
Copy link
Member

zombieJ commented Apr 22, 2020

看看是不是空格转 tab 了?这个还是要弄回来的。

@wufeng87
Copy link
Author

嗯,是回车换行影响了,我给退回去重新提交了。

@wufeng87
Copy link
Author

@zombieJ 麻烦看看,这样处理有问题吗

@zombieJ zombieJ merged commit c6e5ae8 into react-component:6.x Apr 24, 2020
@zombieJ
Copy link
Member

zombieJ commented Apr 24, 2020

+ rc-table@6.10.15

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.

2 participants