Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/src/controls/form/combo_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ class ComboBox<T> extends StatefulWidget {
this.focusNode,
this.autofocus = false,
this.popupColor,
this.onOpenChanged,
// When adding new arguments, consider adding similar arguments to
// ComboBoxFormField.
});
Expand Down Expand Up @@ -971,6 +972,12 @@ class ComboBox<T> extends StatefulWidget {
/// The callback will not be invoked if the combo box button is disabled.
final VoidCallback? onTap;

/// Called when the dropdown opens or closes.
///
/// This callback is invoked with `true` when the dropdown is shown
/// and `false` when it's hidden.
final ValueChanged<bool>? onOpenChanged;

/// A builder to customize the combo box buttons corresponding to the
/// [ComboBoxItem]s in [items].
///
Expand Down Expand Up @@ -1155,6 +1162,7 @@ class ComboBoxState<T> extends State<ComboBox<T>> {
void closePopup() {
_comboboxRoute?._dismiss();
_comboboxRoute = null;
widget.onOpenChanged?.call(false);
}

void _handleFocusChanged() {
Expand Down Expand Up @@ -1232,7 +1240,7 @@ class ComboBoxState<T> extends State<ComboBox<T>> {
barrierLabel: FluentLocalizations.of(context).modalBarrierDismissLabel,
popupColor: widget.popupColor,
);

widget.onOpenChanged?.call(true);
navigator.push(_comboboxRoute!).then<void>((
_ComboBoxRouteResult<T>? newValue,
) {
Expand Down
4 changes: 4 additions & 0 deletions lib/src/controls/form/editable_combo_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class EditableComboBox<T> extends ComboBox<T> {
super.items,
super.onChanged,
super.onTap,
super.onOpenChanged,
super.placeholder,
super.selectedItemBuilder,
super.style,
Expand Down Expand Up @@ -231,6 +232,7 @@ class ComboboxFormField<T> extends FormField<T> {
Widget? disabledPlaceholder,
required this.onChanged,
VoidCallback? onTap,
ValueChanged<bool>? onOpenChanged,
int elevation = 8,
TextStyle? style,
Widget icon = const WindowsIcon(WindowsIcons.chevron_down),
Expand Down Expand Up @@ -278,6 +280,7 @@ class ComboboxFormField<T> extends FormField<T> {
disabledPlaceholder: disabledPlaceholder,
onChanged: onChanged == null ? null : state.didChange,
onTap: onTap,
onOpenChanged: onOpenChanged,
elevation: elevation,
style: style,
icon: icon,
Expand Down Expand Up @@ -353,6 +356,7 @@ class EditableComboboxFormField<T> extends FormField<T> {
Widget? placeholder,
Widget? disabledPlaceholder,
required this.onChanged,
ValueChanged<bool>? onOpenChanged,
VoidCallback? onTap,
int elevation = 8,
TextStyle? style,
Expand Down
Loading