Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Aug 5, 2016

  • Fixes a couple of JS errors in the autocomplete that were caused by assumptions that the input would always be a string.
  • Adds a warning for cases where the display value doesn't evaluate to a string.
  • Cleans up a few redundant expressions.

Note: There's still a JS error when clearing the value, but it should be fixed with #9221.

Fixes #9242.

@crisbeto crisbeto added the needs: review This PR is waiting on review from the team label Aug 5, 2016
@crisbeto crisbeto force-pushed the 9242/autocomplete-warning branch from 17e3eb3 to 53235b7 Compare August 5, 2016 19:27
var itemText = getItemText(item) || item;

if (itemText && !angular.isString(itemText)) {
$log.warn('Could not resolve display value to a string. Please check the `md-item-text` attribute.');
Copy link
Member

Choose a reason for hiding this comment

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

Can we please prefix that (probably like this) ?

md-autocomplete: The resolved text for an item is not a string. Please check the `md-item-text` attribute.`

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, I'll put it in.

@crisbeto crisbeto force-pushed the 9242/autocomplete-warning branch from 53235b7 to b512d66 Compare August 5, 2016 19:37
return $q.when(getItemText(item) || item);
var itemText = getItemText(item) || item;

if (itemText && !angular.isString(itemText)) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really sure about that check, because $scope.itemText can also return a promise as a value.

http://codepen.io/DevVersion/pen/KrGxaQ (Simple example)

I think it would be better to chain into the returned promise and add the check there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I didn't know that was a use case.

… display value isn't a string

* Fixes a couple of JS errors in the autocomplete that were caused by assumptions that the input would always be a string.
* Adds a warning for cases where the display value doesn't evaluate to a string.
* Cleans up a few redundant expressions.

**Note:** There's still a JS error when clearing the value, but it should be fixed with angular#9221.

Fixes angular#9242.
@crisbeto crisbeto force-pushed the 9242/autocomplete-warning branch from b512d66 to cf42ba2 Compare August 5, 2016 19:48
@devversion
Copy link
Member

LGTM.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: review This PR is waiting on review from the team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete: useless error thrown when md-item-text is missing
3 participants