Skip to content

Reactivity not working correctly when updating array of references #831

Closed
@karatekaneen

Description

@karatekaneen

Reproduction

I have a document that has an array with references:

files: [
	'collection/document1',
	'collection/document2',
	'collection/document3',
	'collection/document4',
] 

and in my component I've bound the containing document with $bind:

this.$bind('allGuidelines', guidelineCollection, { maxRefDepth: 0 })

and it works correctly where my files prop is an array of strings.
But when I update the document in another part of the code like:

const files = guideline.files.filter(f => f.path !== 'collection/document2')
await db.collection(col).doc(docId).update({ files })

The bound document is updated but instead of removing the correct item it removes the last item.

Expected:

files: [
	'collection/document1',
	'collection/document3',
	'collection/document4',
] 

Actual:

files: [
	'collection/document1',
	'collection/document2',
	'collection/document3',
] 

When reloading the page the data is correct so this problem only occurs when bound.

Am I doing anything wrong or can this problem be avoided somehow?

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