Skip to content

Commit

Permalink
crmUi - more reliable method of checking whether autocomplete element…
Browse files Browse the repository at this point in the history
… needs updating
  • Loading branch information
colemanw committed Jun 13, 2023
1 parent def56d4 commit 4332a9a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ang/crmUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,15 +755,12 @@
};

if (ctrl.ngModel) {
var oldValue;
// Ensure widget is updated when model changes
ctrl.ngModel.$render = function() {
element.val(ctrl.ngModel.$viewValue || '');
// Trigger change so the Select2 renders the current value,
// but only if the value has actually changed (to avoid recursion)
if (!angular.equals(ctrl.ngModel.$viewValue, oldValue)) {
oldValue = ctrl.ngModel.$viewValue;
element.change();
if (!angular.equals(ctrl.ngModel.$viewValue || '', element.val())) {
element.val(ctrl.ngModel.$viewValue || '').change();
}
};

Expand Down

0 comments on commit 4332a9a

Please sign in to comment.