Skip to content

Commit 9865ba9

Browse files
authored
feat: doubleclick on drag handle resets position (#795)
1 parent f6f1665 commit 9865ba9

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/extension/app/components/plugin/plugin-action-bar.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,16 @@ export class PluginActionBar extends ConnectedElement {
504504
this.setAttribute('dragging', 'true');
505505
};
506506

507+
/**
508+
* Handle double click
509+
*/
510+
onDblClick = () => {
511+
if (this.hasAttribute('style')) {
512+
// reset to default position
513+
this.removeAttribute('style');
514+
}
515+
};
516+
507517
/**
508518
* Constrain the element to viewport bounds
509519
*/
@@ -584,7 +594,7 @@ export class PluginActionBar extends ConnectedElement {
584594
}
585595

586596
return html`
587-
<div class="logo" @mousedown="${this.onDragStart}" title="${this.appStore.i18n('drag_to_reposition')}">
597+
<div class="logo" @mousedown="${this.onDragStart}" @dblclick="${this.onDblClick}" title="${this.appStore.i18n('drag_to_reposition')}">
588598
<div class="drag-handle"></div>
589599
${ICONS.SIDEKICK_LOGO}
590600
</div>

test/app/components/plugin/plugin-action-bar.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,18 @@ describe('Plugin action bar', () => {
15571557
expect(actionBar.getAttribute('dragging')).to.be.null;
15581558
});
15591559

1560+
it('resets position to default on double-click', () => {
1561+
// Simulate a dragged position
1562+
actionBar.style.left = '50%';
1563+
actionBar.style.transform = 'translate(100px, 0px)';
1564+
actionBar.style.bottom = '20px';
1565+
expect(actionBar.hasAttribute('style')).to.be.true;
1566+
1567+
actionBar.onDblClick();
1568+
1569+
expect(actionBar.hasAttribute('style')).to.be.false;
1570+
});
1571+
15601572
it('prevents text selection during drag', () => {
15611573
// Start drag
15621574
actionBar.onDragStart(new MouseEvent('mousedown', {

0 commit comments

Comments
 (0)