[英]React-Select 1.0.0-rc.5 - Select doesn't open when clicking inside after choosing an option
我从react-select库中以最新版本(1.0.0-rc.5)实现了Select组件。
我可以单击“选择”元素以打开列表。 我选择一个值,这将关闭列表并显示我选择的值。 但是,当我再次单击该元素以显示选项列表时,什么也没有发生。 只有在我单击鼠标后(可能在模糊事件之后),它才会打开列表。
我尝试通过使用autoBlur = {true}道具来解决此问题,但无法在IE 11中切换到页面上的下一个元素。
我确实注意到在演示页面上没有发生这种情况,该页面仍使用0.9.1版。
有人知道为什么会这样吗?
编辑
这是我班的一个例子
export class TestSelect extends React.Component {
constructor(props) {
super(props);
}
updateValue = (selectedItem) => {
this.setState({ selectValue: selectedItem });
if (this.props.onChange) {
this.props.onChange(selectedItem);
}
}
render() {
return (
<div id={this.props.id} className="form-styling">
<Label text="React Select" />
<br/><br />
<Select
options={this.props.options}
className="select-class"
clearable={false}
onChange={this.updateValue}
/>
</div>
);
}
}
这是实现该类的页面
const TestPage = () =>{
return(
<TestSelect
id="select-id"
options={testSelectOptions}
/>);
}
export const testSelectOptions = [
{ value: '1', label: 'Option 1' },
{ value: '2', label: 'Option 2' },
{ value: '3', label: 'Option 3' }
];
export default TestPage;
我想到了。 选择一个选项时,我的输入的最小宽度设置为95%。
这将导致在尝试单击下拉列表内部时输入event.target.tagName,这将导致代码在激发任何焦点事件之前返回。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.