Skip to content

Commit d1763ee

Browse files
bso-odooFrancoisGe
authored andcommitted
carousel: select first slide on save
1 parent 321ac4f commit d1763ee

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

addons/html_builder/static/src/plugins/carousel_option_plugin.js

+11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ export class CarouselOptionPlugin extends Plugin {
5151
on_snippet_dropped_handlers: this.onSnippetDropped.bind(this),
5252
normalize_handlers: this.normalize.bind(this),
5353
on_reorder_items_handlers: this.reorderCarouselItems.bind(this),
54+
before_save_handlers: () => {
55+
const proms = [];
56+
for (const carouselEl of this.editable.querySelectorAll(".carousel")) {
57+
const firstItem = carouselEl.querySelector(".carousel-item");
58+
if (firstItem.classList.contains("active")) {
59+
continue;
60+
}
61+
proms.push(this.slide(carouselEl, 0));
62+
}
63+
return Promise.all(proms);
64+
},
5465
};
5566

5667
getActions() {

0 commit comments

Comments
 (0)