Semantic UI React - Input in Dropdown does not allow space

岁酱吖の 提交于 2021-01-29 16:26:29

问题


I have a dropdown with nested text inputs. After adding onClick={event => event.stopPropagation()} to the inputs I am able to select an input and type in it, however as soon as I press the space bar the dropdown is closed.

I have worked out that adding multiple or closeOnChange={false} to the dropdown keeps the dropdown open, however the onChange of the input is not fired, which means that the space is not added to the string and it effectively results in a noop.

I have created a simple pen to show the issue which may be found here.


回答1:


Quick and dirty solution would be to add

    onKeyUp = {(e) => {
      if (e.keyCode === 32) {
        e.target.value = e.target.value + " " 
        e.stopPropagation()}
      }
    }

to the Input



来源:https://stackoverflow.com/questions/59699902/semantic-ui-react-input-in-dropdown-does-not-allow-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!