The drop event does not propagate properly in Edge browser

I have a website with a draggable table where users can drag and drop items to rearrange them.

Although it works perfectly on Chrome and Firefox, I'm having trouble getting it to function properly on Edge.

When debugging on Edge, all properties of the event object show errors.

Below is the code snippet:

TypeScript

dragEnd(event) {
event.target.style.opacity = '1';
}

drag(event, questionId: number) {
event.dataTransfer.setData('questionId', questionId);
const element: HTMLTableRowElement = event.target;
element.style.opacity = '0.4';
}

allowDrop(ev) {
ev.dataTransfer.dropEffect = 'move';
ev.preventDefault();
}

drop(event, themeId: number) {
const target = event.target.parentElement;
this.moveRow(Number(event.dataTransfer.getData('questionId')), this.stripCharacters(target.id));
this.updateSaveOrderButton(themeId);
}

 moveRow(source: number, target: number) {
let questions: Question[] = this.evaluation.themes.find
  (t => t.id === this.getQuestionById(source).theme_id).questions;

const sourceIndex: number = questions.findIndex(q => q.evaluation_question_id === source);
const targetIndex: number = questions.findIndex(q => q.evaluation_question_id === target);

if (questions.find(q => q.evaluation_question_id === target) && sourceIndex !== targetIndex)
  questions = this.arrayMove(questions, sourceIndex, targetIndex);

}}

HTML

 <tr [id]="'questionrow' + question.evaluation_question_id" *ngFor="let question of theme.questions; let index = index"
                class="draggable" draggable="true" (dragend)="dragEnd($event)" (drop)="drop($event, theme.id)"
                (dragstart)="drag($event, question.evaluation_question_id)" (dragover)="allowDrop($event)">

Answer №1

I stumbled upon the solution.

It seems that Edge is more stringent in terms of types compared to other browsers. The drag methods need to have their event parameters specified as DragEvent type.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Building a reusable Button component in React using TypeScript that handles not assignable type errors

Attempting to create a reusable component in reactjs using typescript is currently resulting in the following error: Type '{ children: string; type: string; }' is not assignable to type 'DetailedHTMLProps<ButtonHTMLAttributes<HTMLButt ...

Insert a blank row at the top of the grid in Wijmo for Angular 2

I am attempting to insert a new empty row at the start of the grid when an external button is clicked. The grid is displaying correctly. <wj-flex-grid #flex [itemsSource]="data" [isReadOnly]="true" [headersVisibility]="'Column' ...

Ensure that an input control consistently displays the value it is linked to

Here is the code snippet of the component: @Component({ template: ` <form> <label>Enter your name:</label> <input #name name="name" [ngModel]="firstName" (change)="onNameChange(name.value)"> </form> <p>Y ...

Struggling to generate a navigation bar in Angular, however, it is not appearing on the localhost screen

I need help with displaying a navigation bar using Angular. I have added the necessary code in nav.component.html, but the navbar is not appearing on my localhost. Could you please take a look at my code and let me know if there are any errors? Below is t ...

Adding input fields dynamically

I have a component named home with 3 input fields for Country, City, and State. You can see them in the image below: https://i.sstatic.net/ZMXfD.png I've implemented dynamic addition of input fields, and it's functioning well as shown in the im ...

The function onClick in Chart.js allows for passing the selected object in Typescript

In the documentation for Chart.js, I found a reference to an onClick function that is triggered whenever a click event occurs on the chart. The code snippet provided looks like this: options: { onClick: this.Function } Function(event, array){ ... } ...

`How can I successfully publish an Angular2 Component to npm while keeping the templateUrl html file separate?`

I have embarked on the task of creating an Angular2 library that includes various Components. My goal is to package this library as an npm module, allowing me to easily install and utilize it in my other Angular2 projects using npm install. To achieve thi ...

I'm fresh to the world of Angular and I'm looking to display a modal with form details to confirm before submitting the form

Instead of immediately submitting the details when signing up, I would like to show the form details filled by the user in a modal first. The user can then choose to submit the form or go back and edit the details. Using Angular, how can we implement a fe ...

Display a loading indicator for all HTTP requests and conceal views until they are finished utilizing the HttpInterceptor

I am just starting to learn angular2. Could someone provide a detailed tutorial on how to implement a loader indicator for each http request, and hiding the view until data is fully loaded while waiting for the loader indicator's timer to finish usin ...

Issue encountered while implementing a recursive type within a function

I've created a type that recursively extracts indices from nested objects and organizes them into a flat, strongly-typed tuple as shown below: type NestedRecord = Record<string, any> type RecursiveGetIndex< TRecord extends NestedRecord, ...

Troubleshooting cross-origin resource sharing header issue between Django backend and Angular frontend

After implementing CORS on my Django backend using the django-cors-headers package and following the steps outlined in the documentation at https://github.com/OttoYiu/django-cors-headers, I performed these specific actions: pip install django-cors-header ...

The jsPdf library performs well on medium-sized screens like laptops, but when downloaded from larger monitor screens, the PDF files do not appear properly aligned

In the code snippet below, I am using html2canvas to convert HTML to PDF. The PDF download works fine on medium screens, but when viewed on larger screens, some pages appear blank and the content order gets shuffled. How can I resolve this issue so that th ...

What is the procedure for disabling validation in the onValueChanged function within Angular?

Is there a way to disable validation in the onValueChanged function in Angular? Check out this demo I have a form where I change the device value upon completion. However, every time I click on the device (in the onValueChanged function), it triggers the ...

When "console.log" is included as an argument in the subscribe() method for an observable

Typically, when I want to display some results from an observable, my process usually looks like this. const source = interval(3000); const transform = source.pipe(scan((acc, num) => [...acc, num], [])); transform.subscribe(res => console.log("% ...

The interconnectivity between ngAfterViewInit in Angular's LifeCycle and observables

enable.service.ts @Injectable({ providedIn: 'root' }) export class EnableService { isEnabled$ = from(this.client.init()).pipe( switchMap(() => this.client.getEnabled()), map(([enabled, isAdmin]) => ({enabled: true, isAdmin: fals ...

Ways to utilize and display data in a *ngFor loop

I have created a simple service for accessing an HTTP service. Can anyone help me with how to bind this service information in *ngFor? import { Component } from '@angular/core'; import {Http } from '@angular/http'; import { In ...

Only show a single li element in CSS at a time

I'm working with Angular 2 and I have a list: <ul> <li *ngFor="let show of (ann)"> {{show}} </li> </ul> I want to show one item from the list every 3 seconds in an infinite loop. Here&apos ...

What is the best way to keep an item from list A after it has been moved to list B using PrimeNg's drag and drop feature?

I am facing an issue with the drag and drop feature in PrimeNg. I have a container that contains both a table and an unordered list. My goal is to be able to drag an element from the unordered list and drop it into the table, while still retaining the drag ...

Is it possible to render dynamic components based on the input property of the parent?

Essentially, I have a top-level component called "Pageview" that showcases various instances of a specific component being utilized. The component being displayed can be changed by providing a route input property to the Pageview component. My goal is to s ...

The MaxDuration feature for a 5-minute time limit is malfunctioning on the Serverless Pro Plan, resulting in a 504 ERROR on

I am currently using Next.js@latest with App Directory My application is hosted on Vercel I'm experiencing a 504 error from Vercel and I'm on the pro plan. My serverless functions are set to run for up to 5 minutes, but usually, they only take ...