question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion list hidden below next UI element

See original GitHub issue

Hi,

I am making an address form where country, state and city are autocompletable inputs. When placing the Autocomplete elements one below the other the only the bottom most list is showing properly. The lists of the Autocomplete elements above are getting hidden behind the bottom elements.

screen shot 2017-04-24 at 5 33 59 pm

  renderAddressForm = () => {
  const address = this.state.formLabel === 'Edit Address' ? this.state.submitAddress : this.state.addressOffline;

  const { countryQuery, searchCountry, stateQuery, searchState } = this.state;
  const countries = this.findCountry(countryQuery);
  const states = this.findState(stateQuery);

return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'white', paddingBottom: 5 }}>

  <Text style={{ padding: 5, fontSize: 15 }}>{this.state.formLabel}</Text>
  
  <View style={{ flexDirection: 'row', marginTop: 2 }}>
    <View style={{ flex: 0.3, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginLeft: 10 }}>
      <Text style={{ fontSize: 15 }}>Street</Text>
    </View>
    <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginRight: 10 }}>
      <Item style={{ flex: 1, paddingLeft: 10, borderRadius: 5, backgroundColor: '#e5e5e5' }}>
        <Input
          placeholder='Enter Street'
          onChangeText={(text) => this.onChangeStreet(text)}
          value={address.street}
          onContentSizeChange={(event) => {
			this.setState({ streetHeight: event.nativeEvent.contentSize.height });
          }}
          style={{ height: Math.max(35, this.state.streetHeight), fontSize: 16 }} />
      </Item>
    </View>
  </View>


  <View style={{ flexDirection: 'row', marginTop: 2 }}>
    <View style={{ flex: 0.3, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginLeft: 10 }}>
      <Text style={{ fontSize: 15 }}>Area</Text>
    </View>
    <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginRight: 10 }}>
      <Item style={{ flex: 1, paddingLeft: 10, borderRadius: 5, backgroundColor: '#e5e5e5' }}>
        <Input
          placeholder='Enter Area'
          onChangeText={(text) => this.onChangeArea(text)}
          value={address.area}
          onContentSizeChange={(event) => {
            this.setState({ areaHeight: event.nativeEvent.contentSize.height });
          }}
          style={{ height: Math.max(35, this.state.areaHeight), fontSize: 16 }} />
        </Item>
    </View>
  </View>

  <View style={{ flexDirection: 'row', marginTop: 2 }}>
    <View style={{ flex: 0.3, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginLeft: 10 }}>
      <Text style={{ fontSize: 15 }}>Landmark</Text>
    </View>
    <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginRight: 10 }}>
      <Item style={{ flex: 1, paddingLeft: 10, borderRadius: 5, backgroundColor: '#e5e5e5' }}>
        <Input
          placeholder='Enter Landmark'
          onChangeText={(text) => this.onChangeLandmark(text)}
          value={address.landmark}
          onContentSizeChange={(event) => {
            this.setState({ landmarkHeight: event.nativeEvent.contentSize.height });
          }}
          style={{ height: Math.max(35, this.state.landmarkHeight), fontSize: 16 }} />
        </Item>
    </View>
  </View>

  <View style={{ flexDirection: 'row', marginTop: 2 }}>
    <View style={{ flex: 0.3, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginLeft: 10 }}>
      <Text style={{ fontSize: 15 }}>Pincode</Text>
    </View>
    <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginRight: 10 }}>
      <Item style={{ flex: 1, paddingLeft: 10, borderRadius: 5, backgroundColor: '#e5e5e5' }}>
        <Input
          placeholder='Enter Pincode'
          onChangeText={(text) => this.onChangePincode(text)}
          value={address.pincode}
          style={{ height: 35, fontSize: 16 }} />
      </Item>
    </View>
  </View>

  <View style={{ flexDirection: 'row', marginTop: 2 }}>
    <View style={{ flex: 0.3, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginLeft: 10 }}>
      <Text style={{ fontSize: 15 }}>Country</Text>
    </View>
    <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginRight: 10 }}>
      <Autocomplete
        placeholder='Select Country'
        autoCorrect={false}
        data={searchCountry ? countries : []}
        onChangeText={(text) => this.setState({
          countryQuery: text,
          searchCountry: true,
        })}
        style={{ height: 35, fontSize: 16, paddingLeft: 18, borderRadius: 5, backgroundColor: '#e5e5e5' }}
        defaultValue={countryQuery}
        containerStyle={{ flex: 1 }}
        inputContainerStyle={{ borderWidth: 0 }}
        listStyle={{ zIndex: 2, position: 'absolute' }}
        renderItem={item => (
          <TouchableOpacity onPress={() => this.onSelectCountry(item)}>
            <Text style={{ fontSize: 15, margin: 2 }}>{item.name}</Text>
          </TouchableOpacity>
        )}
      />
    </View>
  </View>

  <View style={{ flexDirection: 'row', marginTop: 2 }}>
    <View style={{ flex: 0.3, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginLeft: 10 }}>
      <Text style={{ fontSize: 15 }}>State</Text>
    </View>
    <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', marginRight: 10 }}>
      <Autocomplete
        placeholder='Select State'
        autoCorrect={false}
        data={searchState ? states : []}
        onChangeText={(text) => this.setState({
          stateQuery: text,
          searchState: true,
        })}
        style={{ height: 35, fontSize: 16, paddingLeft: 18, borderRadius: 5, backgroundColor: '#e5e5e5' }}
        defaultValue={stateQuery}
        containerStyle={{ flex: 1 }}
        inputContainerStyle={{ borderWidth: 0 }}
        listStyle={{ zIndex: 2, position: 'absolute' }}
        renderItem={item => (
          <TouchableOpacity onPress={() => this.onSelectState(item)}>
            <Text style={{ fontSize: 15, margin: 2 }}>{item.name}</Text>
          </TouchableOpacity>
        )}
      />
    </View>
  </View>

</View>
 );
}//end of renderAddressForm

How can I get the country suggestion list to appear on top of the state list ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

4reactions
panuhorsmalahticommented, Mar 8, 2018

The problem is probably caused by this: “every new view creates a zIndex stacking context.”. In other words, if the later element which is on top of the autocomplete input creates a new view, no zIndex setting will solve it. I fixed it by moving both the autocomplete and the next component to the same view.

2reactions
hdornier-reeliantcommented, Jun 22, 2018

With this configuration:

<View container with higher zIndex>
   <Autocomplete>
</view>
<View with results />

I achieve to have the suggestions above the result view.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQueryUI autocomplete hidden behind modal - Stack Overflow
I'm using a jQuery UI modal essentially the same as this. When I open my page and click to open a modal for...
Read more >
UI Page hide or show field based on option select - ServiceNow
Solved: Hi All , I have a ui page as below . I have a requirement when I select "User" from the dropdown...
Read more >
aria-autocomplete - Accessibility - MDN Web Docs - Mozilla
Autocompletion is user interface feature wherein inline suggestions are made as a user types in an input. Suggested text for completing the ...
Read more >
Dropdown | NextUI - Beautiful, fast and modern React UI Library
Displays a list of actions or options that a user can choose. ... Button: A NextUI Button component used as the trigger (includes...
Read more >
9 UX Best Practice Design Patterns for Autocomplete ...
Despite search autocomplete suggestions being common, ... When other UI elements (e.g., sticky headers, the main nav, buttons, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found