Skip to content

Commit 58509fa

Browse files
authored
Improve select option group boundary case. (#373)
1 parent dd91421 commit 58509fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/SelectOptionGroup/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ class SelectOptionGroup extends Component {
4040
resetMenuStyle = () => {
4141
if (!this.optionGroupRef) return;
4242
const { isInModal, position } = this.props;
43-
const { top, height } = this.optionGroupRef.getBoundingClientRect();
43+
const { top, height, width } = this.optionGroupRef.getBoundingClientRect();
4444
if (isInModal) {
4545
if (position.y + position.height + height > window.innerHeight) {
4646
this.optionGroupRef.style.top = (position.y - height) + 'px';
4747
}
48+
if (position && position.x + width > window.innerWidth) {
49+
this.optionGroupRef.style.left = (window.innerWidth - width - 10) + 'px';
50+
}
4851
this.optionGroupRef.style.opacity = 1;
4952
this.searchInputRef.current && this.searchInputRef.current.inputRef.focus();
50-
}
51-
else {
53+
} else {
5254
if (height + top > window.innerHeight) {
5355
const borderWidth = 2;
5456
this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';

0 commit comments

Comments
 (0)