You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Mobile: Scroll dropdown to selected value when first opened (#11091)
This commit is contained in:
		| @@ -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} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user