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

Commit 96a58c1

Browse files
alorenzennshahan
authored andcommitted
Migrate MaterialDropdownSelectComponent from OnChanges to AfterChanges.
Since ngOnChanges only tracked a single input, we can instead track a bool ourselves. PiperOrigin-RevId: 242508648
1 parent 0788aff commit 96a58c1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

angular_components/lib/material_select/material_dropdown_select.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class MaterialDropdownSelectComponent<T> extends MaterialSelectBase<T>
9494
KeyboardHandlerMixin,
9595
ActivateItemOnKeyPressMixin<T>,
9696
ShiftClickSelectionMixin<T>
97-
implements PopupSizeProvider, OnChanges, OnDestroy {
97+
implements PopupSizeProvider, AfterChanges, OnDestroy {
9898
/// Function for use by NgFor for optionGroup.
9999
///
100100
/// Avoids recreating the DOM for the optionGroup.
@@ -175,6 +175,14 @@ class MaterialDropdownSelectComponent<T> extends MaterialSelectBase<T>
175175

176176
final ChangeDetectorRef _changeDetector;
177177

178+
bool _disabledChanged = false;
179+
180+
@override
181+
set disabled(bool value) {
182+
super.disabled = value;
183+
_disabledChanged = true;
184+
}
185+
178186
MaterialDropdownSelectComponent(
179187
@Optional() IdGenerator idGenerator,
180188
@Optional() @SkipSelf() this._popupSizeDelegate,
@@ -457,14 +465,15 @@ class MaterialDropdownSelectComponent<T> extends MaterialSelectBase<T>
457465
}
458466

459467
@override
460-
ngOnChanges(Map<String, SimpleChange> changes) {
461-
if (changes.containsKey('disabled') && disabled) {
468+
void ngAfterChanges() {
469+
if (_disabledChanged && disabled) {
462470
close();
463471
}
472+
_disabledChanged = false;
464473
}
465474

466475
@override
467-
ngOnDestroy() {
476+
void ngOnDestroy() {
468477
_optionsListener?.cancel();
469478
_selectionListener?.cancel();
470479
}

0 commit comments

Comments
 (0)