-
Notifications
You must be signed in to change notification settings - Fork 201
Description
When using react-native-element-dropdown with a pre-selected value and a long list (e.g. language selector), the dropdown unexpectedly scrolls back to the selected item the moment scrolling stops — even if the user is browsing a different part of the list.
This happens because the autoScroll prop is true by default. When scrolling ends (or the dropdown is focused/blurred), the dropdown aggressively jumps to the currently selected value — disrupting user experience.
This behavior is not intuitive and is not clearly documented.
Steps to Reproduce
- Use a dropdown with a long list of items (50+)
- Set an initial selected value (e.g., "English")
- Scroll far down the dropdown list (e.g., to "Japanese")
- Pause for a second — or lift your finger
- Observe: the dropdown snaps back up to "English" immediately
import React, { useState } from "react";
import { View } from "react-native";
import { Dropdown } from "react-native-element-dropdown";
const translationLanguages = [
{ code: "en", label: "English" },
{ code: "fr", label: "French" },
{ code: "es", label: "Spanish" },
{ code: "ja", label: "Japanese" },
{ code: "ko", label: "Korean" },
{ code: "zh", label: "Chinese" },
// ...many more
];
export default function App() {
const [language, setLanguage] = useState(() =>
translationLanguages.find((l) => l.code === "en")
);
return (
<View style={{ padding: 20 }}>
<Dropdown
data={translationLanguages}
labelField="label"
valueField="code"
value={language}
placeholder="Select Language"
onChange={(item) => {
const match = translationLanguages.find(l => l.code === item.code);
setLanguage(match);
}}
autoScroll={true} // This causes the snapping behavior
search
maxHeight={250}
/>
</View>
);
}
Setting autoScroll={false}
solves the issue completely:
This behavior should either:
Be clearly documented in the README
Default to false, especially in lists with more than X items
Allow for smarter scroll behavior (e.g., only scroll on first open, not during interactions)