Column moving and pinning are not always working correctly
Description
Column moving and pinning are not always working correctly
- igniteui-angular version: 6.1.x
- browser: all
Steps to reproduce
- Run column moving demo
- Pin 'ContactName', 'ContactTitle', 'Address' via the corresponding buttons.
- Start moving the 'ID' column over the pinned area until the drop indicator is shown between 'ContactTitle' and 'Address'.
- Drop the header being dragged.
Result
'ID' column is reorder after the 'Address' column.
Expected result
'ID' column is reorder before the 'Address' column.
This behavior is observed if the index of the column that we are trying to pin is smaller than the index of the pinned column that is a drop target.
There is another scenario that causes inconsistent behavior:
- Run column moving demo.
- Pin 'ContactName', 'ContactTitle', 'Address' columns in the following order: ContactTitle, Address, ContactName.
- Start moving the 'ID' column over the pinned area until the drop indicator is shown between 'ContactTitle' and 'Address'.
- Drop the header being dragged.
Result: 'ID' column goes at the end, column order is not correct as a whole.
This behavior is cause as a result of calling the reinitPinStates() method each time the columnList is reset. reinitPinStates will filter the pinned columns according to the way they appear in the ColumnList collection which will only works correctly if this order matches the visible indexes order. Otherwise pinned columns order is not the one expected by the end user.
May be we should additionally sort the pinned columns by the visible index in the reinitPinStates() method. However this might break some other logic as this method is called each time ColumnList is reset.
@rkaraivanov what do you think?