Skip to content

Layout watcher doesn't use deep #44

@OwenMelbz

Description

@OwenMelbz

Hi - We're having problems getting the grid to redraw on changes to the layout prop.

We've got some code that dynamically sets the height of the grid e.g.

this.layout[index].position.h = this.howeverManyRowsNeeded(component.$el)

However, the current watcher fails to notice the change as it's not watching the positions keys within the layout array.

watch: {
  layout (newLayout) {
    if (this.fixLayoutOnLoad) {
      if (utils.layoutHasCollisions(newLayout)) {
        this.updateLayout(utils.fixLayout(newLayout, this.bubbleUp))
      }
    }
  }
}

To resolve this you'd need to enable deepWatching you could do this by telling the watcher to use deep watching e.g.

watch: {
  layout: {
    handler(newLayout) {
      if (this.fixLayoutOnLoad) {
        if (utils.layoutHasCollisions(newLayout)) {
          this.updateLayout(utils.fixLayout(newLayout, this.bubbleUp))
        }
      }
    },
    deep: true
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions