Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

[changed] set the position of the menu as fixed #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ let Autocomplete = React.createClass({
value: '',
wrapperProps: {},
wrapperStyle: {
display: 'inline-block'
display: 'inline-block',
position: 'relative',
},
inputProps: {},
onChange () {},
Expand All @@ -39,9 +40,9 @@ let Autocomplete = React.createClass({
background: 'rgba(255, 255, 255, 0.9)',
padding: '2px 0',
fontSize: '90%',
position: 'fixed',
position: 'absolute',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the title of you PR be: "Set the position of menu as "absolute" instead of "fixed""?

overflow: 'auto',
maxHeight: '50%', // TODO: don't cheat, let it flow to the bottom
maxHeight: '50vh',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is browser support for vh enough to use it?

}
}
},
Expand Down Expand Up @@ -236,12 +237,9 @@ let Autocomplete = React.createClass({
var node = this.refs.input
var rect = node.getBoundingClientRect()
var computedStyle = global.window.getComputedStyle(node)
var marginBottom = parseInt(computedStyle.marginBottom, 10) || 0;
var marginLeft = parseInt(computedStyle.marginLeft, 10) || 0;
var marginRight = parseInt(computedStyle.marginRight, 10) || 0;
this.setState({
menuTop: rect.bottom + marginBottom,
menuLeft: rect.left + marginLeft,
menuWidth: rect.width + marginLeft + marginRight
})
},
Expand Down Expand Up @@ -281,8 +279,6 @@ let Autocomplete = React.createClass({
})
})
var style = {
left: this.state.menuLeft,
top: this.state.menuTop,
minWidth: this.state.menuWidth,
}
var menu = this.props.renderMenu(items, this.props.value, style)
Expand Down