FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ObservableArray does not notify correctly when splice replaces elements · Issue #7425 · NativeScript/NativeScript · GitHub

ObservableArray does not notify correctly when splice replaces elements #7425

Description

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: next
  • Cross-platform modules: next
  • Android Runtime: next
  • iOS Runtime: next

Describe the bug
When you call ObservableArray.splice(), the event it emits fails to account for replaced items. This means it accounts only for removals/inserts, but any replace returns an added count of 0

To Reproduce
https://play.nativescript.org/?template=play-ng&id=jVKVft

Expected behavior
addedCount should take into account the replaced items

Additional context
Maybe we should change addedCount to this._array.length + removed.length - oldLength

I ran into this issue trying to splice FormattedString.spans. The only way I could make it work was by either:

  1. removing and adding again
  2. applying the addedCount fix I proposed

Since ObservableArray is used almost everywhere, this change could be breaking.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL