Skip to content

Commit

Permalink
Merge pull request oi-narendra#133 from oi-narendra/127-dropdown-over…
Browse files Browse the repository at this point in the history
…lay-should-be-close-automatically-on-single-item

Fix: Close dropdown on single select.
  • Loading branch information
oi-narendra authored Aug 17, 2024
2 parents 11d5185 + 36ae963 commit 42d5ac0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/src/controllers/multiselect_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class MultiSelectController<T> extends ChangeNotifier {
)
.toList();

debugPrint('items: $_items');
notifyListeners();
_onSelectionChanged?.call(_selectedValues);
}
Expand Down
6 changes: 6 additions & 0 deletions lib/src/multi_dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ class _MultiDropdownState<T extends Object> extends State<MultiDropdown<T>> {
_dropdownController.toggleWhere((element) => element == item);
}
_formFieldKey.currentState?.didChange(_dropdownController.selectedItems);

if (widget.singleSelect) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_dropdownController.closeDropdown();
});
}
}

InputDecoration _buildDecoration() {
Expand Down

0 comments on commit 42d5ac0

Please sign in to comment.