Commit 77785a3
authored
fix: reset cell order according to order of columns in DOM (#11522)
## Description
Since #10632 reordering
columns per drag and drop physically reorders cells instead of applying
an order through CSS. Note that this does not actually reorder the
columns in the DOM, so it only establishes a new "visual order". When
changing the order of columns in the DOM afterwards programmatically,
`_renderColumnTree` will recreate rows with the correct cell order, and
`_updateOrders` will reset the `_order` property to be in sync with the
DOM order again.
When setting a column order in the Flow component, it will reorder
columns in the DOM, which triggers the path above. However, if the order
of columns in the DOM already match the new order, this path would not
trigger. For that the Flow component additionally calls `_updateOrders`,
which is not effective anymore as it only updates the `_order` prop, but
doesn't reorder cells to reset the visual order. The use case is
basically:
- User reorders columns
- Then clicks a button to restore initial column order
- DOM order doesn't actually change, cells are neither regenerated or
reordered
In order to fix this, this adds a `_resetColumnOrder` method that the
Flow component can use to force reset the visual order to the DOM order.
The method force recreates the column tree, similar to what would happen
when the column DOM order actually changes. The method also
short-circuits when the visual and DOM order are already in sync. This
works for the Flow component, as the mutation observer / column tree
update debouncer run before the `executeJs` call, so the Flow component
should be able to call this unconditionally without having to detect
whether column order actually changed.
Part of vaadin/flow-components#9119
## Type of change
- Bugfix1 parent ff1f9ff commit 77785a3
2 files changed
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
340 | 370 | | |
341 | 371 | | |
342 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
438 | 458 | | |
439 | 459 | | |
440 | 460 | | |
| |||
0 commit comments