我有一个自定义模式,里面有 2 个反应选择组件。模态主体已准备好自动滚动,以防内容超出其大小,但反应选择组件下拉列表会在模态内部打开并出现溢出,这正是我不想要的。没有溢出,它工作正常。
我正在使用 CSS 模块。
<div className={styles.modalBody}>
{this.props.children}
</div>
.modalBody {
padding: padding;
flex: 1 1 auto;
height: 45vh;
max-height: 100%;
overflow: auto;
}
<Select
id={this.props.id}
className={styles[this.props.selectType ? this.props.selectType : 'selectWhite']}
classNamePrefix="select"
name={this.props.name}
value={selectedOption ? selectedOption : this.props.value}
placeholder={this.props.placeholder}
onChange={this.onChange}
options={this.props.options}
isDisabled={this.props.disabled}
isSearchable={false}/>
我怎样才能解决这个问题?
谢谢你! :)
你想看看menuPortalTarget
支柱。有一个高级文档中有关此主题的内容 https://react-select.com/advanced#portaling,特别是提供了一个模态示例。就像是:
<Select
{...otherProps}
menuPortalTarget={document.body} />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)