Skip to content

[bug report] Uncaught TypeError: Cannot read properties of undefined (reading '0') Source Error Model #1110

Open
@ndoteddy

Description

@ndoteddy

REQUIRED: Before filing a bug report

Change each [ ] to [x] when you have done it.

Describe the bug (required)

A clear and concise description of what the bug is. What did you do, and what
did you expected to happen? What happened instead?

To Reproduce (required)

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

If your issue appears in a larger codebase and it you can't pin down why it is
happening, please

  • Fork this StackBlitz template
  • Update it to the latest ng2-dragula
  • Modify it, and reproduce the issue
  • Add a link to it here.

Screenshots (optional)

SourceModelIssue

If applicable, add screenshots to help explain your problem.
<div [dragula]="'WorkOrder'" [(dragulaModel)]="day.WorkOrders"
class="__gridCellContainer"
[attr.data-row-id]="rowId" [attr.data-cell-id]="cellId"
[attr.data-tech-id]="tech.SapId" *ngIf="day.WorkOrders">

<work-order *ngFor="let workOrderEntry of day.WorkOrders; index as cellIndex"
[selectedWorkOrders]="selectedWorkOrders" ...... >

For normal flow its working fine but when something occured in the child component (e.g something change/updated)
we notice the placeholder of the "container" is totally change and drake unable to match the container with newly updated container (we also have put change detection to ensure the cycle being refresh)

Versions (required)
Version : 5.1.0
https://www.npmjs.com/package/ng2-dragula/v/5.1.0

Please state which versions of the following packages you have installed:
"@angular/core": "^18.2.9",
"ng2-dragula": "^5.1.0",

Browsers affected (optional)
Microsoft Edge

Is this a bug in a particular browser? If so, it's unlikely that it's a problem with ng2-dragula. Instead, it is probably a bug in dragula.

Additional context (optional)

<div [dragula]="'WorkOrder'" [(dragulaModel)]="day.WorkOrders" (dragulaModelChange)="WorkOrder = $event" class="__gridCellContainer" [attr.data-row-id]="rowId" [attr.data-cell-id]="cellId" [attr.data-tech-id]="tech.SapId"> <work-order *ngFor="let workOrderEntry of day.WorkOrders; index as cellIndex" [selectedWorkOrders]="selectedWorkOrders" [selectedWorkOrdersForMove]="selectedWorkOrdersForMove" [grid]="grid" [weekDays]="weekDays" [rowId]="rowId" [cellId]="cellId" [cellIndex]="cellIndex" [workOrderEntry]="workOrderEntry"

We are using NG2-Dragula but for some cases we found the bug inside the ng2-dragula
when the source of model is undefined eventhough we have define it in angular template as above

the issue has occured before drop event being hit -
and because source model undefined its throw unhandling exception inside library itself

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions