Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Dragging template menu items into expanded dropdown bodies placed items outside the dropdown instead of inside. This broke after migrating from dragular to Angular CDK drag-drop.

Root Cause

Dropdown bodies lacked unique IDs and weren't included in the template menu's cdkDropListConnectedTo array, preventing CDK from routing drops correctly.

Changes

navigation-menu-page.component.ts

  • Added getDropdownId(index) to generate unique IDs (dropdown-0, dropdown-1, ...)
  • Added connectedDropdownIds getter to dynamically build array of all dropdown IDs for connection binding

navigation-menu-page.component.html

  • Assigned unique [id] to each dropdown body via getDropdownId(firstLevelIndex)
  • Updated template menu's cdkDropListConnectedTo to ['actualMenuList'].concat(connectedDropdownIds)
// Component
get connectedDropdownIds(): string[] {
  return this.navigationMenuModel.actualMenu
    .map((item, index) => item.type === NavigationMenuItemTypeEnum.Dropdown ? this.getDropdownId(index) : null)
    .filter(id => id !== null) as string[];
}
<!-- Template menu now connects to all dropdowns -->
<div cdkDropList [cdkDropListConnectedTo]="['actualMenuList'].concat(connectedDropdownIds)" id="mainMenu">

<!-- Each dropdown gets unique ID -->
<div cdkDropList [id]="getDropdownId(firstLevelIndex)" [cdkDropListConnectedTo]="['mainMenu']">

This establishes bidirectional connections allowing template items to drop into any dropdown body.

Original prompt

This section details on the original issue you should resolve

<issue_title>dragging a menuitem into dropdown does not work</issue_title>
<issue_description>When dragging a menuitme into an expanded dropdown places the menuitem outside the dropdown instead of inside of it. This was working before the refactor from dragular to dnd</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix dragging menuitem into dropdown issue Fix drag-and-drop into dropdown menu items Nov 11, 2025
Copilot AI requested a review from renemadsen November 11, 2025 17:40
@renemadsen renemadsen marked this pull request as ready for review November 11, 2025 18:04
@renemadsen renemadsen merged commit ab9ea56 into master Nov 11, 2025
13 of 16 checks passed
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.

dragging a menuitem into dropdown does not work

3 participants