Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS和部分安卓机型点击词缀后瞬间消失问题采坑解决方案 #11

Open
zx86119 opened this issue Dec 9, 2019 · 0 comments

Comments

@zx86119
Copy link

zx86119 commented Dec 9, 2019

点击词缀是调用了keyTap事件,IOS会调用blur事件,所以IOS只要在wxml里把bindblur事件取消就能解决。
安卓部分机型比较复杂,如华为p10,调用keyTap事件后,还会调用input,然后又调用blur事件,上面已经把blur事件取消,但是input事件不可能取消吧。所以想了一个笨办法,在wxSearch.js里增加一个开关变量,var banInput=false;
在wxSearchKeyTap第一行增加banInput = true;
在wxSearchInput第一行增加if (banInput) { banInput = !banInput;return;}
这样就保证keyTap事件后的第一次input事件失效

但同时也带来一个问题,有的机型不会在keyTap后调用input,比如ios。如果这样设置ios在keyTap后的第一次输入会失效
因此又在wxSearchKeyTap里增加一个定时器,setTimeout(()=>{ banInput=false;},200)
200ms后将banInput恢复,用户手速再快,也不至于200ms内去输入吧

综上,问题基本绕的过去。最后感谢作者的贡献,3年前的项目还有这么多人star

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

No branches or pull requests

1 participant