当前位置:网站首页>antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
2022-04-23 19:29:00 【庸人°】
问题
说一下问题出现的需求场景,需要点击出现一个下拉框,不同的下拉框对应不同的Modal组件,包括显示账号信息,禁用/启用账号并填写原因等需求。就是用的Dropdown组件+Modal+Input.Textarea组件来做,做完以后发现出了一点bug。文本域中点击上下左右键,光标不随着移动。
解决办法
经过排查,发现Dropdown内如果点击选中MenuItem后,不使其回缩,会发现,在文本域中输入文字后,如果点击上下键,光标不动,但是MenuItem的选中会跟着键盘事件移动。这说明MenuItem或者Menu对键盘事件也有监听。应该是这里做了什么事情导致文本域光标的移动失效了,那该怎么解决呢,最后发现在文本域上或者MenuItem绑定onKeyDown事件在其中阻止事件冒泡e.stopPropagation(); ,就不会有影响了。
后来尝试了一下,这个问题并不是dropdown引起的,而是Menu,即使我们单独使用Menu组件来实现与Modal+文本域也会出现类似问题。阻止事件冒泡即可解决。
问题出现原因分析

猜测会出现这个问题的原因是,键盘事件在文本域中修改光标后,冒泡到Menu中,根据点击的上下左右键,来移动MenuItem的选中效果,此时会将焦点从文本域移到MenuItem中,就会出现,上下左右键无法控制光标的问题。
版权声明
本文为[庸人°]所创,转载请带上原文链接,感谢
https://blog.csdn.net/wuxian_wj/article/details/124347506
边栏推荐
- MFC obtains local IP (used more in network communication)
- TI DSP的 FFT与IFFT库函数的使用测试
- Kubernetes入门到精通-KtConnect(全称Kubernetes Toolkit Connect)是一款基于Kubernetes环境用于提高本地测试联调效率的小工具。
- 2021-2022-2 ACM training team weekly Programming Competition (8) problem solution
- Openlayers 5.0 loading ArcGIS Server slice service
- Openlayers 5.0 thermal diagram
- ESP8266-入门第一篇
- Mfcc: Mel frequency cepstrum coefficient calculation of perceived frequency and actual frequency conversion
- 命令-sudo
- 【webrtc】Add x264 encoder for CEF/Chromium
猜你喜欢

ESP8266-入门第一篇

Common SQL commands

No, some people can't do the National Day avatar applet (you can open the traffic master and earn pocket money)

Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)

MySQL syntax collation

Openharmony open source developer growth plan, looking for new open source forces that change the world!

RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`

Zero cost, zero foundation, build profitable film and television applet

【webrtc】Add x264 encoder for CEF/Chromium

Use of fluent custom fonts and pictures
随机推荐
数据分析学习目录
Steps to build a deep learning environment GPU
Openlayers 5.0 loading ArcGIS Server slice service
Class loading mechanism
ArcMap connecting ArcGIS Server
Efficient serial port cyclic buffer receiving processing idea and code 2
Pit encountered using camera x_ When onpause, the camera is not released, resulting in a black screen when it comes back
What is a message queue
数据库查询 - 选课系统
Speculation on the way to realize the smooth drag preview of video editing software
Inject Autowired fields into ordinary beans
[webrtc] add x264 encoder for CEF / Chromium
MFC obtains local IP (used more in network communication)
First experience of using fluent canvas
对普通bean进行Autowired字段注入
深度学习环境搭建步骤—gpu
Speex维纳滤波与超几何分布的改写
MySQL syntax collation (2)
MySQL数据库 - 连接查询
Physical meaning of FFT: 1024 point FFT is 1024 real numbers. The actual input to FFT is 1024 complex numbers (imaginary part is 0), and the output is also 1024 complex numbers. The effective data is