primevue icon indicating copy to clipboard operation
primevue copied to clipboard

DataTable: Wrong position of column after reordering

Open haasson opened this issue 2 years ago • 2 comments

Describe the bug

Hello, there is a bug on columns reordering. See screenshots.

Open the example in documentation https://www.primefaces.org/primevue/datatable/reorder . Try to place Code column between Name and Category. If you release mouse button when your cursor is over the Name category (picture 1) - you'll get an expected result. But if you move your cursor to Category column and the release mouse button - Code column will be placed between Category and Quantity (but helper arrows still points to Name and Category border - see picture 2).

Снимок экрана 2022-07-21 в 10 06 01 Снимок экрана 2022-07-21 в 10 08 34

Reproducer

No response

PrimeVue version

3.12.1

Vue version

3.x

Language

ALL

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

haasson avatar Jul 21 '22 09:07 haasson

I think this has been fixed: see #2225

nclemeur avatar Aug 10 '22 22:08 nclemeur

@nclemeur thank you for your reply. The description of bug is definitely the same, but as I can see changes do nothing: https://github.com/primefaces/primevue/pull/2614/files I've upgraded a primevue version, and bug is still here. I took a look at the code, and it turns out that dropIndex defines in a wrong way. It is just index of column on which is a cursor: https://github.com/primefaces/primevue/blob/master/src/components/datatable/DataTable.vue#L1284 I guess the center of column should be calculated, like for helper arrows here: https://github.com/primefaces/primevue/blob/master/src/components/datatable/DataTable.vue#L1252 And the final dropIndex value should be calculated considering on which side of column the cursor is.

haasson avatar Aug 11 '22 09:08 haasson

The indicator's position is so important in this case, not the cursor. DataTable drops the draggable column in front of the indicator position. This is expected behavior. Please check this behavior again.

tugcekucukoglu avatar Oct 21 '22 14:10 tugcekucukoglu

The indicator's position is so important in this case, not the cursor. DataTable drops the draggable column in front of the indicator position. This is expected behavior. Please check this behavior again.

I attached two pictures. The indicator on the same position on both of them. But the result of moving of column completely different. Result depends on cursor position. If indicator points between Name and Category columns, I expect to see moved columns there. I can record a video, but you can easily check it on your site

haasson avatar Oct 21 '22 14:10 haasson

Thanks for the update. We'll reconsider it.

tugcekucukoglu avatar Oct 24 '22 06:10 tugcekucukoglu

I have exactly the same problem and have to add that the DataTableColumnReorderEvent actually returns the position of the indicator and not the cursor.

This means the position of the column in the UI does not necessarily match the dropIndex of the event.

This inconsistency just makes it impossible for me to implement a logic based on the reordering.

jrebmann avatar Mar 30 '23 11:03 jrebmann

Could you check the latest version? If the problem still persist, please create a new issue with a reproducer link.

tugcekucukoglu avatar Oct 30 '23 09:10 tugcekucukoglu