Skip to content

Commit a92e11f

Browse files
committed
restrict dragging for regular button cards to the drag handle only.
1 parent e7a278f commit a92e11f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

popup-page-scripts/popup-page-customButtons.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ function createButtonCardElement(button, index) {
2424
const buttonItem = document.createElement('div');
2525
buttonItem.className = 'button-item';
2626
buttonItem.dataset.index = index;
27-
buttonItem.draggable = true; // Ensure the item is draggable
2827

2928
if (button.separator) {
3029
buttonItem.classList.add('separator-item');
30+
buttonItem.draggable = true; // Separators are draggable as a whole item.
3131
buttonItem.innerHTML = `
3232
<div class="separator-line"></div>
3333
<span class="separator-text">Separator</span>
3434
<div class="separator-line"></div>
3535
<button class="delete-button danger">Delete</button>
3636
`;
3737
} else {
38+
// For regular buttons, only the drag handle is draggable, not the whole card.
3839
buttonItem.innerHTML = `
3940
<div class="drag-handle" draggable="true">&#9776;</div>
4041
<input type="text" class="emoji-input" value="${button.icon}">
@@ -152,12 +153,8 @@ let draggedItem = null;
152153
let lastDragPosition = { x: 0, y: 0 };
153154

154155
function handleDragStart(e) {
155-
// Define interactive elements that should not initiate dragging.
156-
const interactiveTags = ['INPUT', 'TEXTAREA', 'BUTTON', 'SELECT'];
157-
if (interactiveTags.includes(e.target.tagName)) {
158-
// Do not initiate drag when interacting with these elements.
159-
return;
160-
}
156+
// Since dragging is now restricted to specific handles or separator items,
157+
// we can be sure that if a drag starts, it's intentional.
161158
const buttonItem = e.target.closest('.button-item');
162159
if (buttonItem) {
163160
isDragging = true;
@@ -435,3 +432,4 @@ function textareaSaverAndResizerFunc() {
435432
});
436433
}
437434

435+

0 commit comments

Comments
 (0)