Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit 599d4df

Browse files
creismannshahan
authored andcommitted
Fix MaterialDropdownSelect type error when clicking a deselect item.
PiperOrigin-RevId: 225102087
1 parent c0e542b commit 599d4df

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

angular_components/lib/material_select/shift_click_selection.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import 'package:angular_components/model/selection/selection_options.dart';
1111

1212
/// Handles toggling selection of a range of options when shift is held down
1313
/// while clicking on the end value.
14-
abstract class ShiftClickSelectionMixin<T> implements ActivationHandler<T> {
14+
//
15+
// This class must support handling the deselect item as well as normal items,
16+
// so it cannot implement [ActivationHandler<T>].
17+
abstract class ShiftClickSelectionMixin<T>
18+
implements ActivationHandler<dynamic /* T | String */ > {
1519
T _pivot;
1620

1721
SelectionModel<T> get selection;
@@ -48,9 +52,11 @@ abstract class ShiftClickSelectionMixin<T> implements ActivationHandler<T> {
4852
/// If [event] is not a [MouseEvent] it will not be handled. This method
4953
/// does handle mouse events even if shift is not held down.
5054
@override
51-
bool handle(UIEvent event, T activatedValue) {
55+
bool handle(UIEvent event, dynamic activatedValue) {
5256
if (selection is! MultiSelectionModel || event is! MouseEvent) return false;
53-
_handleClick(event, activatedValue);
57+
// The deselect label is never shown with a MultiSelectionModel, so it's
58+
// safe to assume activatedValue is of type T at this point.
59+
_handleClick(event, activatedValue as T);
5460
return true;
5561
}
5662
}

0 commit comments

Comments
 (0)