react-component / select

React Select
https://select.react-component.now.sh/
MIT License
892 stars 452 forks source link

fix: dont scrollIntoView when options length changed #984

Closed littleee closed 8 months ago

littleee commented 8 months ago

fixed #982

vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
select ❌ Failed (Inspect) Oct 11, 2023 11:49am
codecov[bot] commented 8 months ago

Codecov Report

Merging #984 (fa87050) into master (d5442ba) will not change coverage. The diff coverage is n/a.

:exclamation: Current head fa87050 differs from pull request most recent head eaa891b. Consider uploading reports for the commit eaa891b to get more accurate results

@@           Coverage Diff           @@
##           master     #984   +/-   ##
=======================================
  Coverage   99.78%   99.78%           
=======================================
  Files          38       38           
  Lines        1373     1373           
  Branches      393      375   -18     
=======================================
  Hits         1370     1370           
  Misses          3        3           
Files Coverage Δ
src/OptionList.tsx 99.33% <ø> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

yoyo837 commented 8 months ago

长度不变内容变了呢?

littleee commented 8 months ago

长度不变内容变了呢?

给个场景? 内容变指的是searchValue吗? searchValue变了保持原逻辑不就可以吗?

yoyo837 commented 8 months ago

flattenOptions 长度不变内容变时

littleee commented 8 months ago

flattenOptions 长度不变内容变时

我个人理解哈, 本次改动并不会对 长度不变内容变 这种情况造成影响,还是和原逻辑一致。 当前改动只是去掉了flattenOptions.length的监听。 我写了个demo验证了一下原逻辑和改动后的逻辑是保持一致的,均不会跳转到active项

afc163 commented 8 months ago

这个删掉会不会导致原问题还出现 https://github.com/ant-design/ant-design/issues/40625

littleee commented 8 months ago

这个删掉会不会导致原问题还出

https://github.com/ant-design/ant-design/issues/40625 这个issue里面关联的pr并没有解决掉该issue的问题, 40625的问题依然存在。 看了下代码, 没有第一次没有出现滚动条的原因是因为rc-virtual-list组件里面有两个属性 listItemHeightlistHeight,默认值分别为200和20, 也就是说只有当item大于10个的时候才会出现滚动条。 之所以能滚动是因为item现在是24px的高度, 然后rc-virtual-list是按照20计算的, 所以就导致了超出了列表的高度但是没有滚动条。 anyway... 显然这是另一个问题了, 与当前pr无关。 下图可以看到,最新antd版本第一次打开依然没有滚动条 image

yoyo837 commented 8 months ago

Close by https://github.com/react-component/select/pull/986

littleee commented 8 months ago

lol

Close by #986