Skip to content

Commit

Permalink
fix(Select): popupComponent do not need syncWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon committed Aug 7, 2019
1 parent 737f7e4 commit 71d7943
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/select/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class Base extends React.Component {
if (width && this.width !== width) {
this.width = width;

if (this.popupRef && this.props.autoWidth) {
if (this.popupRef && this.shouldAutoWidth()) {
// overy 的 node 节点可能没有挂载完成,所以这里需要异步
setTimeout(() => {
if (this.popupRef && this.popupRef.getInstance().overlay) {
Expand Down Expand Up @@ -386,7 +386,6 @@ export default class Base extends React.Component {
const {
prefix,
mode,
autoWidth,
locale,
notFoundContent,
useVirtual,
Expand Down Expand Up @@ -421,7 +420,9 @@ export default class Base extends React.Component {
const menuProps = {
children,
role: 'listbox',
style: autoWidth ? { width: this.width } : { minWidth: this.width },
style: this.shouldAutoWidth()
? { width: this.width }
: { minWidth: this.width },
selectedKeys,
focusedKey: highlightKey,
focusable: false,
Expand Down Expand Up @@ -548,6 +549,14 @@ export default class Base extends React.Component {
}
};

shouldAutoWidth() {
if (this.props.popupComponent) {
return false;
}

return this.props.autoWidth;
}

render(props) {
const {
prefix,
Expand All @@ -557,7 +566,6 @@ export default class Base extends React.Component {
popupClassName,
popupStyle,
popupContent,
autoWidth,
canCloseByTrigger,
followTrigger,
cache,
Expand Down Expand Up @@ -605,7 +613,9 @@ export default class Base extends React.Component {
{popupContent ? (
<div
className={`${prefix}select-popup-wrap`}
style={autoWidth ? { width: this.width } : {}}
style={
this.shouldAutoWidth() ? { width: this.width } : {}
}
>
{popupContent}
</div>
Expand Down

0 comments on commit 71d7943

Please sign in to comment.