Files
openfoodnetwork/app/webpacker/controllers/out_of_stock_modal_controller.js
Gaetan Craig-Riou 4e62e20fa8 Fix test to work with new jsdom restriction
since jsdom 21, it's no longer possible to mock window.location
See : https://github.com/jsdom/jsdom/issues/3492
2025-11-11 14:58:48 +11:00

21 lines
555 B
JavaScript

import { Controller } from "stimulus";
import { locationPathName } from "js/window_location_wrapper";
// This is meant to be used with the "modal:closing" event, ie:
//
// <div data-controller="out-of-stock-modal"
// data-action="moda:closing@out-of-stock-modal#redirect"
// data-out-of-stock-modal-redirect-value="true"
// >
// </div>
//
export default class extends Controller {
static values = { redirect: { type: Boolean, default: false } };
redirect() {
if (this.redirectValue) {
locationPathName("/shop");
}
}
}