[FIX] web_editor: make moving images within wall wrap around
When using the previous button in an image wall, the image wraps around but skips the last position. When using the next button in an image wall, the image does not wrap around. This commit fixes this inconsistency by using the same behavior as the one in 15.0 since [1]: wrap through all positions in both directions. Steps to reproduce: - Drop an "Images Wall" snippet. - Add 6 images. - Select an image. - Click repeatedly on "Move to previous". => The image wraps around all positions except the last one. - Click repeatedly on "Move to next". => The image does not move anymore once it reached the last position. [1]: https://github.com/odoo/odoo/commit/3931f0a67f904daea6c891a3a80aa984760a7682 task-2990053 X-original-commit: 054f480376e8d08d1582cedd6caec6455be828e2 Part-of: odoo/odoo#125758
This commit is contained in:
@@ -8318,6 +8318,11 @@ registry.GalleryHandler = SnippetOptionWidget.extend({
|
||||
if (name === "reoder_items") {
|
||||
const itemsEls = this._getItemsGallery();
|
||||
const oldPosition = itemsEls.indexOf(data.itemEl);
|
||||
if (oldPosition === 0 && data.position === "prev") {
|
||||
data.position = "last";
|
||||
} else if (oldPosition === itemsEls.length - 1 && data.position === "next") {
|
||||
data.position = "first";
|
||||
}
|
||||
itemsEls.splice(oldPosition, 1);
|
||||
switch (data.position) {
|
||||
case "first":
|
||||
|
||||
Reference in New Issue
Block a user