Skip to content

Commit

Permalink
fix: clear reference to element removed from split-layout (#7367) (#7368
Browse files Browse the repository at this point in the history
)

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
vaadin-bot and web-padawan authored Apr 29, 2024
1 parent 4af11f8 commit 0e54057
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/split-layout/src/vaadin-split-layout-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export const SplitLayoutMixin = (superClass) =>
_cleanupNodes(nodes) {
nodes.forEach((node) => {
if (!(node.parentElement instanceof this.constructor)) {
node.removeAttribute('slot');
const slot = node.getAttribute('slot');
if (slot) {
this[`_${slot}Child`] = null;
node.removeAttribute('slot');
}
}
});
}
Expand Down
16 changes: 16 additions & 0 deletions packages/split-layout/test/split-layout.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,22 @@ describe('removing nodes', () => {
await nextFrame();
expect(first.hasAttribute('slot')).to.be.false;
});

it('should not update splitter position on the removed node', async () => {
splitLayout.removeChild(second);
await nextFrame();
track(splitLayout.$.splitter, -10, 0);
expect(second.style.flex).to.be.not.ok;
});

it('should not dispatch `splitter-dragend` event if node is removed', async () => {
const spy = sinon.spy();
splitLayout.addEventListener('splitter-dragend', spy);
splitLayout.removeChild(second);
await nextFrame();
track(splitLayout.$.splitter, -10, 0);
expect(spy.called).to.be.false;
});
});

describe('moving nodes between layouts', () => {
Expand Down

0 comments on commit 0e54057

Please sign in to comment.