Skip to content

Conversation

@remco-k
Copy link

@remco-k remco-k commented May 23, 2025

The title says it all I guess. I needed to be able to drag-drop the items in de webinterface, so I've added that in a simple way. Hopefully you can add it to your repo as well so other users can benefit from it.

@debloper debloper requested a review from Copilot May 28, 2025 11:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds drag-and-drop functionality for rearranging items in the web interface. Key changes include the introduction of drag event handlers in the script, updating the HTML template to include a draggable attribute and a drag handle, and styling adjustments to indicate a dragging element.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
web/script.js Added the initDragAndDrop function with drag event listeners.
web/index.html Updated the URL template to mark items as draggable and styled the drag handle.

},
initDragAndDrop() {
const list = document.querySelector('#urls .list-group');

Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a check to verify that the 'list' element exists before binding drag event listeners, to prevent potential runtime errors if the element is missing.

Suggested change
if (!list) {
console.warn("Element '#urls .list-group' not found. Drag-and-drop functionality will not be initialized.");
return;
}

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this.


<template id="template-url">
<li class="list-group-item text-truncate fs-3">
<li class="list-group-item text-truncate fs-3" draggable="true">
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding ARIA attributes (e.g., aria-grabbed) to this draggable element to improve accessibility for keyboard and assistive technology users.

Suggested change
<li class="list-group-item text-truncate fs-3" draggable="true">
<li class="list-group-item text-truncate fs-3" draggable="true" aria-grabbed="false" role="listitem" aria-dropeffect="move">

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, if you want to add.

Copy link
Owner

@debloper debloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍 thanks!

Will need to test it out on a device before merging the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants