Repository navigation
Update GridStack when item options change - #62
Conversation
|
@btecu thanks for your work on this issue! Can we add some testing around this bug? |
|
@jkusa this is related to the internal state of the |
|
Looks like existing hooks (https://github.com/yahoo/ember-gridstack/blob/master/addon/components/grid-stack-item.js#L79) that interact with the GridStack instance are not tested. I'm guessing there might not be a way. |
|
@btecu what behaviors did you observe before and after your change? |
|
@balajimanoharan @jkusa what's the status here? |
|
Sorry about the delay. Im ok with merging this now, while we figure out a way to test gridstack interactions. @jkusa do you still have concerns? |
|
@btecu yes sorry for the delay. Could you use your |
|
@jkusa test added. |
|
@btecu thanks for adding the test. Unfortunately, it looks like the test passes even without your change. |
|
@jkusa As I wrote earlier, the issue is related to some internal state of GridStack. |
kevinhinterlong
left a comment
There was a problem hiding this comment.
@btecu it looks like from your example that without this method, the onChange method is never called, but after the change it is.
So you should be able to test this by making something like
assert.expect(1);
this.set('onChange', () => assert.ok(true, 'onChange was called after changing GridStackItem options'));
this.set('options', { x: 0, y: 0, width: 5, height: 1 });
await render(hbs`
<GridStack @onChange={{this.onChange}}>
<GridStackItem @options={{this.options}}>
Test
</GridStackItem>
</GridStack>
`);
this.set('options', { x: 2, y: 1, width: 12, height: 1 });| didUpdateAttrs() { | ||
| super.didUpdateAttrs(...arguments); | ||
|
|
||
| let parent = this.parentContainer; |
There was a problem hiding this comment.
| let parent = this.parentContainer; | |
| const parent = this.parentContainer; |
|
|
||
| let parent = this.parentContainer; | ||
| if (parent && parent.gridStack) { | ||
| let { height, width, x, y } = this.options; |
There was a problem hiding this comment.
| let { height, width, x, y } = this.options; | |
| const { height, width, x, y } = this.options; |
|
Hey @btecu, regarding:
I get that. From your demo app & GIFs the |
|
@jkusa I've updated the test to check whether |
| let parent = this.parentContainer; | ||
| if (parent && parent.gridStack) { | ||
| let { height, width, x, y } = this.options; | ||
| parent.gridStack.update(this.element, x, y, width, height); |
There was a problem hiding this comment.
If we do this for height, width, x, y do we need to keep attributeBindings for height, width, x, y?
There was a problem hiding this comment.
I'm not sure there is any benefit in adding an exclusion list. It would be nice to remove the attributeBindings completely, since they are not supported in glimmer components.
There was a problem hiding this comment.
I think the benefit would be not updating the DOM multiple times (with update() & with attributeBindings) when grid-stack-item args update. It also would be nice to have a single path to set x, y, width, height (and all args).
It would be nice to remove the attributeBindings
Totally agree 👍
I spoke with a gridstack maintainer on slack, looks like direct attribute updates are not officially supported. I filed an issue for this enhancement. Another issue is that not all item options are supported in the current update() method. I filed an issue for that too :).
Given, the need for a larger refactor, I think we can merge this and clean up the flow separately.
Thanks for your work on this 👍
There was a problem hiding this comment.
I can fix the GridStack.update() to take all options (easy) but not sure I will get to (or should) track DOM changes to update internal state.
Closes #61.