mirror of
https://github.com/maputnik/editor.git
synced 2026-08-25 14:37:27 +00:00
Added MAX_HEIGHT constant.
This commit is contained in:
@@ -4,6 +4,8 @@ import classnames from 'classnames'
|
|||||||
import Autocomplete from 'react-autocomplete'
|
import Autocomplete from 'react-autocomplete'
|
||||||
|
|
||||||
|
|
||||||
|
const MAX_HEIGHT = 140;
|
||||||
|
|
||||||
class AutocompleteMenu extends React.Component {
|
class AutocompleteMenu extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
keepMenuWithinWindowBounds: PropTypes.bool,
|
keepMenuWithinWindowBounds: PropTypes.bool,
|
||||||
@@ -14,9 +16,11 @@ class AutocompleteMenu extends React.Component {
|
|||||||
calcMaxHeight() {
|
calcMaxHeight() {
|
||||||
if(this.props.keepMenuWithinWindowBounds) {
|
if(this.props.keepMenuWithinWindowBounds) {
|
||||||
const maxHeight = window.innerHeight - this.autocompleteMenuEl.getBoundingClientRect().top;
|
const maxHeight = window.innerHeight - this.autocompleteMenuEl.getBoundingClientRect().top;
|
||||||
if(maxHeight != this.state.maxHeight) {
|
const limitedMaxHeight = Math.min(maxHeight, MAX_HEIGHT);
|
||||||
|
|
||||||
|
if(limitedMaxHeight != this.state.maxHeight) {
|
||||||
this.setState({
|
this.setState({
|
||||||
maxHeight: maxHeight
|
maxHeight: limitedMaxHeight
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +36,7 @@ class AutocompleteMenu extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
maxHeight: 90
|
maxHeight: MAX_HEIGHT
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user