mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-27 21:06:49 +00:00
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.
17 lines
378 B
JavaScript
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");
|
|
}
|
|
}
|