Skip to content

Commit c1e9c3e

Browse files
Fix selectedItem not returning currently selected value (fixes AssistoLab#208)
1 parent 1e158c4 commit c1e9c3e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

DropDown/src/DropDown.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ extension DropDown {
955955
and `cellConfiguration` implicitly calls `reloadAllComponents()`.
956956
*/
957957
public func reloadAllComponents() {
958-
DispatchQueue.main.async {
958+
DispatchQueue.executeOnMainThread {
959959
self.tableView.reloadData()
960960
self.setNeedsUpdateConstraints()
961961
}
@@ -1184,3 +1184,13 @@ extension DropDown {
11841184
}
11851185

11861186
}
1187+
1188+
private extension DispatchQueue {
1189+
static func executeOnMainThread(_ closure: @escaping Closure) {
1190+
if Thread.isMainThread {
1191+
closure()
1192+
} else {
1193+
main.async(execute: closure)
1194+
}
1195+
}
1196+
}

0 commit comments

Comments
 (0)