ant-design / ant-design-mobile

Essential UI blocks for building mobile web apps.
https://mobile.ant.design
MIT License
11.64k stars 2.4k forks source link

[SearchBar] 点击 取消的时候 输入框的值被清空 #6433

Closed x011223 closed 11 months ago

x011223 commented 11 months ago

Version of antd-mobile

5.33.0

Operating system and its version

iOS

Browser and its version

ios chrome 110.0

Sandbox to reproduce

https://codesandbox.io/s/nostalgic-haze-n47jch?file=/src/App.tsx

What happened?

点击 取消 的时候输入框的值被清空了,我认为取消的作用应该只是将取消按钮隐藏,SearchBar样式 恢复,清空值的操作应由清除图标完成,否则功能是有交叉的。

另外,预期的是 防止用户误操作点到了输入框,然后点击取消,这时候 取消操作 并保留原来的值,从这个场景看 不清空值是比较合理的,否则 输入框的值被清空之后,那么我们的数据就 需要重新进行搜索并更新页面。

image

Relevant log output

No response

zombieJ commented 11 months ago

预设行为都可以通过受控改掉了:

https://codesandbox.io/s/broken-haze-l8zvch?file=/src/App.tsx