From 8a84e0084fed9e5d4ee700c4887ccecf53bb83af Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 7 Mar 2024 11:42:43 +1100 Subject: [PATCH] Enqueue cable_ready actions to perform at end of reflex I think this resolves [this discussion](https://github.com/openfoodfoundation/openfoodnetwork/pull/11163#discussion_r1260531844) I guess we just didn't know [how it works](https://docs.stimulusreflex.com/guide/cableready.html#order-of-operations) before.. --- app/reflexes/products_reflex.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/reflexes/products_reflex.rb b/app/reflexes/products_reflex.rb index e6dd59e41d..dd56972517 100644 --- a/app/reflexes/products_reflex.rb +++ b/app/reflexes/products_reflex.rb @@ -116,11 +116,11 @@ class ProductsReflex < ApplicationReflex producer_options: producers, producer_id: @producer_id, category_options: categories, category_id: @category_id, flashes: flash }) - ).broadcast + ) cable_ready.replace_state( url: current_url, - ).broadcast_later + ) morph :nothing end @@ -133,7 +133,7 @@ class ProductsReflex < ApplicationReflex cable_ready.replace( selector: "#products-form", html: render(partial: "admin/products_v3/table", locals:) - ).broadcast + ) morph :nothing # dunno why this doesn't work.