diff --git a/frontends/etiquette_flask/templates/album.html b/frontends/etiquette_flask/templates/album.html index cf9b356..85f3276 100644 --- a/frontends/etiquette_flask/templates/album.html +++ b/frontends/etiquette_flask/templates/album.html @@ -395,9 +395,25 @@ function create_child(title) api.albums.create(title, parent_id, api.albums.callback_follow); } +function get_album_card_from_child(element) +{ + /* + Given an element which is known to be a child of an album card, navigate up + the parent tree until we find that album card. + This is used to make drag-and-drop work even when you start your drag by + clicking on the album's thumbnail, title, etc. + */ + while (! element.classList.contains("album_card")) + { + element = element.parentElement; + } + return element; +} + function on_album_drag_start(event) { - event.dataTransfer.setData("text/plain", event.target.id); + let album_card = get_album_card_from_child(event.target); + event.dataTransfer.setData("text/plain", album_card.id); } function on_album_drag_end(event) {