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

Bug Fix: Selected items should not be removed when they are found to be invalid #1359

Closed
wants to merge 2 commits into from

Conversation

meyerds
Copy link
Contributor

@meyerds meyerds commented Dec 16, 2015

A tagged item was getting removed accidentally in the following scenario:

ui-select configuration:

  • tagging

problem code flow:

  1. User enters tag text and accepts the new tag(s) (with tab or the like)
  2. A validator determines that the tag is invalid, and sets the model value of the ui-select instance to undefined. At this point the view value still shows the invalid value.
  3. The items list is refreshed during the tagging process, and is triggered after validators run. The items list on the uiSelectCtrl is updated.
    4.  The item watcher sees the change and causes the view value to be updated from the model value, in order to reflect the data in the fresh items.
  4. Since the model value is undefined until the invalid condition is resolved, the formatters run and create an empty view value, erasing the tagged item(s) - the user does not have an opportunity to resolve the invalid condition, their data is just erased.

solution:

Do not update the view value on items refresh, when the model value is undefined

…ing scenario:

ui-select configuration:
-tagging
-async with refresh delay

problem code flow:
1) user enters tag text and immediately accepts the new tag(s) (with tab or the like), such that the tag is created before the refresh delay expires
2) a validator determines that the tag is invalid, and sets the model value of the ui-select instance to undefined. At this point the view value still shows the invalid value.
3) refresh is triggered after the delay, and updates the items list on the uiSelectCtrl
4)  the item watcher sees the change and causes the view value to be updated from the model value, in order to reflect the data in the fresh items
5) since the model value is undefined until the invalid condition is resolved, the formatters run and create an empty view value, erasing the tagged item(s) - the user does not have an opportunity to resolve the invalid condition, their data is just erased.

solution: do not update the view value on items refresh, when the model value is undefined
@JakePartusch
Copy link

👍

@meyerds
Copy link
Contributor Author

meyerds commented Dec 16, 2015

This pull request should resolve this issue: #981

@meyerds meyerds closed this Feb 25, 2016
@meyerds meyerds reopened this Feb 25, 2016
@wesleycho
Copy link
Contributor

This just needs squashing, but LGTM

@wesleycho wesleycho closed this in 331f819 Apr 6, 2016
fcaballero pushed a commit to fcaballero/ui-select that referenced this pull request Apr 17, 2016
- Prevent accidental removal of a tagged item that subsequently becomes invalid

Closes angular-ui#1359
fcaballero pushed a commit to fcaballero/ui-select that referenced this pull request Apr 25, 2016
- Prevent accidental removal of a tagged item that subsequently becomes invalid

Closes angular-ui#1359
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants