Problem/Motivation
When new displays are created in the Views UI, either using the add display button or the "clone as" feature, they initially appear in the correct order (newest last). However, as soon as the view is saved, the displays are reordered. Perhaps the position isn't being set for new displays?
Steps to reproduce
I started with 8.x standard:
I added some new block displays.
Each time, the unsaved display appeared in the correct position in the UI, and opening the modal dialog (without making any changes) would also show the correct order.
But after saving the view (without having done anything other than add a new display) the displays would be reordered, with the newest floating to the top.
Positions in the saved config entity at the same time (note that the order here bears no relationship to the order in the UI, despite that it is exactly the view being used):
display:
block_3:
position: ''
feed_1:
position: ''
block_1:
position: ''
page_1:
position: { }
block_2:
position: { }
default:
position: { }
block_4:
position: ''It appears that, unless you use the reorder dialog,
position
is stored as an empty string.If I use the reorder dialog, non-empty weights are saved, but the displays are still listed in the wrong order:
display:
block_4:
position: '6'
block_3:
position: '5'
block_1:
position: '2'
feed_1:
position: '3'
default:
position: '0'
page_1:
position: '1'
block_2:
position: '4'And, if I add yet another display to the view, it still floats to the top after saving.
This time, the displays were finally reordered by position in the file, only after saving twice after the reorder:display:
block_5:
position: ''
default:
position: '0'
page_1:
position: '1'
block_1:
position: '2'
feed_1:
position: '3'
block_2:
position: '4'
block_3:
position: '5'
block_4:
position: '6'
Proposed resolution
The underlying problem appears to be that new displays are created with an empty position, which also results in haphazard file ordering on save. Maybe newly created displays should always have the weight of last visible display + 1?
Attachment | Size | Status | Test result | Operations |
---|---|---|---|---|
standard_install.png | 22.44 KB | Ignored | None | None |
adding_a_display.png | 26.19 KB | Ignored | None | None |
no_reorder.png | 26.97 KB | Ignored | None | None |
after_saving.png | 7.22 KB | Ignored | None | None |
after_saving_reorder_dialog.png | 26.89 KB | Ignored | None | None |
too_many_displays.png | 7.72 KB | Ignored | None | None |