diff --git a/ReactNativeClient/lib/components/Dropdown.js b/ReactNativeClient/lib/components/Dropdown.js index 4f35891cb..2d5eec8ed 100644 --- a/ReactNativeClient/lib/components/Dropdown.js +++ b/ReactNativeClient/lib/components/Dropdown.js @@ -17,15 +17,13 @@ class Dropdown extends React.Component { }); } - componentDidMount() { + updateHeaderCoordinates() { // https://stackoverflow.com/questions/30096038/react-native-getting-the-position-of-an-element - setTimeout(() => { - this.headerRef_.measure((fx, fy, width, height, px, py) => { - this.setState({ - headerSize: { x: px, y: py, width: width, height: height } - }); + this.headerRef_.measure((fx, fy, width, height, px, py) => { + this.setState({ + headerSize: { x: px, y: py, width: width, height: height } }); - }, 100); + }); } render() { @@ -107,7 +105,10 @@ class Dropdown extends React.Component { return ( - this.headerRef_ = ref} onPress={() => { this.setState({ listVisible: true }) }}> + this.headerRef_ = ref} onPress={() => { + this.updateHeaderCoordinates(); + this.setState({ listVisible: true }); + }}> {headerLabel} {'▼'}