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

Change $select.clear() so it sets value to null instead of undefined #1908

Conversation

v-andrew
Copy link

@v-andrew v-andrew commented Feb 8, 2017

Type: fix
Scope: uiSelectMatch

Fixes #863

@v-andrew v-andrew changed the title $select.clear() sets value to null $select.clear() sets value to null instead of undefined Feb 8, 2017
@v-andrew
Copy link
Author

v-andrew commented Feb 8, 2017

PR does not add more failing test.
Same tests are failing in the master branch.

@v-andrew v-andrew changed the title $select.clear() sets value to null instead of undefined Change $select.clear() so it set value to null instead of undefined Feb 8, 2017
@v-andrew v-andrew changed the title Change $select.clear() so it set value to null instead of undefined Change $select.clear() so it sets value to null instead of undefined Feb 8, 2017
@Jefiozie
Copy link
Contributor

So i tested your adjustments and local i'm getting the same result. Can you double check at your end.

Thanks.

cloudrick pushed a commit to hardcoretech/ui-select that referenced this pull request Feb 17, 2017
[why] If selection is clear, the value is better to be null.
[how] Merge pull request:
      angular-ui#1908
@Jefiozie
Copy link
Contributor

Hi @v-andrew I think i have found the reason for the failing unit tests. Waiting for some comments why things have changed after this we can probably rebase your PR and the unit test problem will be resolved.

Thanks.

@v-andrew
Copy link
Author

@Jefiozie Thanks
I can rebase it myself, just let me know, when CI issue solved

@Jefiozie
Copy link
Contributor

HI @v-andrew , I have merged my PR could you rebase to the master?
Thanks.

@cloudrick
Copy link

cloudrick commented Feb 22, 2017

Hi @v-andrew

I have two questions:

  1. If the repeat expression of ui-select-choices is like "<ui-select-choices repeat="o.name as o in XXX>",
    the ngModel's value will still be undefined even if we set null to ctrl.
    Maybe we need to modify ngModel.$parsers to skip handling for undefined and null
    Ex:
// From view --> model
ngModel.$parsers.unshift(function (inputValue) {
  // Keep original value for undefined and null
  if (inputValue === undefined || inputValue === null) {
    return inputValue;
  }
  ......
});
  1. In ctrl.select(), does it need to handle null value as undefined value?
    Ex:
  ctrl.select = function(item, skipFocusser, $event) {
    if (item === undefined || item === null || !_isItemDisabled(item)) {
    ......

Thanks

@v-andrew v-andrew force-pushed the fix/clear-should-set-value-to-null branch from 81e5ffb to f4b7f47 Compare February 23, 2017 18:57
@v-andrew
Copy link
Author

@Jefiozie sorry, for the delay, I'm quite busy.
Tests are passing now.

@v-andrew
Copy link
Author

@cloudrick Let me look into it.

@Jefiozie
Copy link
Contributor

Jefiozie commented Mar 7, 2017

Hi @v-andrew , any updates on this PR. Thanks.

@Jefiozie
Copy link
Contributor

Any updates on this issue?

Thanks

@Jefiozie Jefiozie added this to the v0.19.6 milestone Mar 13, 2017
@jrbotros
Copy link

Happy to take this over if you're too busy, @v-andrew!

@Jefiozie
Copy link
Contributor

Jefiozie commented Apr 3, 2017

@v-andrew can @jrbotros have a look at this? based on your most recent updates you have not the time (at the moment) to finish this PR. Could @jrbotros take over?

@jrbotros can you have a look it?

@Jefiozie
Copy link
Contributor

Jefiozie commented Apr 4, 2017

@jrbotros Can you have a look at it?

@jrbotros
Copy link

jrbotros commented Apr 4, 2017

@Jefiozie @v-andrew Happy to take this over, will look to get it finished in the next day or two!

@jrbotros
Copy link

jrbotros commented Apr 5, 2017

@Jefiozie just submitted #1959, let me know what you think!
@v-andrew thanks for getting this started 😊

@Jefiozie
Copy link
Contributor

Closing this down as we are continuing on #1959

@Jefiozie Jefiozie closed this Apr 10, 2017
@Jefiozie Jefiozie removed this from the v0.19.6 milestone Apr 10, 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.

Clearing the selection sets model value to 'undefined'
4 participants