mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
Mobile: Scroll dropdown to selected value when first opened (#11091)
This commit is contained in:
parent
d023ce592c
commit
5c23765458
@ -78,6 +78,17 @@ class Dropdown extends Component<DropdownProps, DropdownState> {
|
||||
private onCloseList = () => {
|
||||
this.setState({ listVisible: false });
|
||||
};
|
||||
private onListLoad = (listRef: FlatList|null) => {
|
||||
if (!listRef) return;
|
||||
|
||||
for (let i = 0; i < this.props.items.length; i++) {
|
||||
const item = this.props.items[i];
|
||||
if (item.value === this.props.selectedValue) {
|
||||
listRef.scrollToIndex({ index: i, animated: false });
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public render() {
|
||||
const items = this.props.items;
|
||||
@ -228,6 +239,7 @@ class Dropdown extends Component<DropdownProps, DropdownState> {
|
||||
accessibilityRole='menu'
|
||||
style={wrapperStyle}>
|
||||
<FlatList
|
||||
ref={this.onListLoad}
|
||||
style={itemListStyle}
|
||||
data={this.props.items}
|
||||
renderItem={itemRenderer}
|
||||
|
Loading…
x
Reference in New Issue
Block a user