Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

fix($selectMultiple): allow user to override getPlaceholder() Behavior #2015

Merged
merged 3 commits into from
Aug 3, 2017

Conversation

DmitryGonchar
Copy link
Contributor

User can provide their custom getPlaceholder() function. E.g. to keep placeholder activated in multipleSelect component, you can use this one:

angular.module('myApp').directive('myAppUiSelectPlaceholderAlwaysVisible', function() {
  return {
    require: 'uiSelect',
    link: function($scope, $element, attrs, $select) {
      $select.getPlaceholder = function () {
        return $select.placeholder;
      }
    }
  }
});

And then add this directive to the <ui-select> html element

closes #1796

@DmitryGonchar
Copy link
Contributor Author

NOTE: user cannot override $selectMultiple.getPlaceholder() function, bc <ui-select-multiple> is appended inside the component. That's why I had to move it to the $select

User can provide their custom `getPlaceholder()` function. E.g. to keep placeholder activated in multipleSelect component, you can use this one:
```
angular.module('myApp').directive('myAppUiSelectPlaceholderAlwaysVisible', function() {
  return {
    require: 'uiSelect',
    link: function($scope, $element, attrs, $select) {
      $select.getPlaceholder = function () {
        return $select.placeholder;
      }
    }
  }
});
```
And then add this directive to the `<ui-select>` html element

closes angular-ui#1796
@@ -65,6 +65,12 @@ uis.controller('uiSelectCtrl',
return isNil(ctrl.selected) || ctrl.selected === '' || (ctrl.multiple && ctrl.selected.length === 0);
};

ctrl.getPlaceholder = function(){
//Refactor single?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this comment?

@@ -15,6 +15,14 @@ describe('ui-select tests', function () {
Escape: 27
};

var multipleTagsTmpl =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use createUiSelectMultiple

Copy link
Contributor

@Jefiozie Jefiozie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments about the PR 😄

@DmitryGonchar
Copy link
Contributor Author

@Jefiozie done

Btw, have you considered splitting tests into multiple files? Better readability, mainainability, it will be clear which tests relate to what and which helper functions available. Also will be easier to run only tests you are working on during dev phase.

@DmitryGonchar
Copy link
Contributor Author

@Jefiozie How about merging this one?

@Jefiozie Jefiozie merged commit 50c6273 into angular-ui:master Aug 3, 2017
@arambert arambert mentioned this pull request Oct 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keep Placeholder activated in multipleSelect component
2 participants