我正在开发添加自定义devtools面板的Chrome扩展程序。我的面板上有一些允许用户输入的文本框,但是,每当我输入问号时,它都会打开Chrome帮助,而不是打出“?”字符。有没有办法阻止这种行为?
更新: 我应该提到我在扩展中使用React,并且正在使用React的综合事件。
答案 0 :(得分:0)
This turned out to be unrelated to Chrome and due to a React JS nuance.
I was trying to call event.stopPropagation() on a React synthetic event which doesn't actually stop propagation to non-react registered event handlers such as the one that opens the help dialog.
The fix was to register a keydown event to the native DOM element and calling stopPropagation on the native event. This properly stoped the help menu from opening in response to typing in my input.
e.g.
<input
ref={input => input.addEventListener(event => event.stopPropagation())}
onChange={this.myOnChangeHandler}
/>