Skip to content

Commit

Permalink
fix!: only set top and left properties on drag
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoCardoso committed Oct 14, 2024
1 parent 1cc5372 commit 6734000
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/dialog/src/vaadin-dialog-draggable-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export const DialogDraggableMixin = (superClass) =>
window.addEventListener('mousemove', this._drag);
window.addEventListener('touchmove', this._drag);
if (this.$.overlay.$.overlay.style.position !== 'absolute') {
this.$.overlay.setBounds(this._originalBounds);
const { top, left } = this._originalBounds;
this.$.overlay.setBounds({ top, left });
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/dialog/test/draggable-resizable.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@ describe('draggable', () => {
expect(Math.floor(draggedBounds.left)).to.be.eql(Math.floor(bounds.left + dx));
});

it('should only change "position", "top", and "left" values on drag', () => {
drag(content);
const overlay = dialog.$.overlay.$.overlay;
const style = overlay.style;
expect(style.length).to.be.eql(3);
expect(style.position).to.be.ok;
expect(style.top).to.be.ok;
expect(style.left).to.be.ok;
});

it('should drag and move dialog if mousedown on element with [class="draggable"] in another shadow root', () => {
drag(dialog.$.overlay.querySelector('internally-draggable').shadowRoot.querySelector('.draggable'));
const draggedBounds = container.getBoundingClientRect();
Expand Down

0 comments on commit 6734000

Please sign in to comment.