3lang3 / react-vant

React mobile UI Components base on Vant
https://react-vant.3lang.dev
MIT License
1.28k stars 182 forks source link

🐛 [Bug]: Picker 组件在通过 form.setFieldValue 设置 value 的问题 #702

Closed tianxing0923 closed 4 months ago

tianxing0923 commented 4 months ago

Which React Vant packages are impacted?

What version of React Vant are you using?

3.3.3

Reproduce live demo(codesandebox or stackblitz)?

https://codesandbox.io/p/sandbox/biao-dan-xiang-lei-xing-forked-d83gzc?file=%2FApp.tsx%3A9%2C12

Descripition

Picker 组件在表单中通过 form.setFieldValue 设置 value 后,在 chrome 下正常,但在 ios safari、微信webview 和 mac safari 内第一次弹出的时候没有选中,关闭后第二次弹出才选中,经过调试发现是 PickerInner 内的 useDebounceEffect 导致,把 wait 设置大一点时没有问题,怀疑是 debounce 内的 setTimeout 浏览器差异所致

测试版本: mac: macOS Monterey (12.1) M1 ios: 17.3.1 safari: 15.2 (17612.3.6.1.6) chrome: 121.0.6167.184 (arm64)