Files
openfoodnetwork/app/webpacker/controllers/product_preview_controller.js
Gaetan Craig-Riou 379e5acfe5 Fix product preview modal opening
The previous solution failed to take into account that it would have been
trigger on any turbo steam rendering action, not just the product preview
one. Now the open event is dispatched when the product preview
controller is connected, which happens when the modal html is rendered.
2024-09-10 13:29:40 +10:00

17 lines
378 B
JavaScript

import { Controller } from "stimulus";
export default class extends Controller {
connect() {
// open the modal when html is rendering to avoid opening a blank modal
this.#open()
}
// private
#open() {
// dispatch "product-preview:open" event to trigger modal->open action
// see views/admin/product_v3/index.html.haml
this.dispatch("open");
}
}