I just spent quite some time creating a custom bloc with 20 custom interactions and I was super disappointed to find out the interactions associated with the bloc didn’t come with it when exported it as a custom bloc.
@Norm For my company, I built an academy using VOLT. I use the Interaction feature to make a search cancel button appear after one of the search buttons is pressed, and it works perfectly. However, how can I make the cancel button visible when using the Volt Blog Search function?
@Norm Let me break it down for you: when a VOLT search string is submitted, the page reloads. Any idea how to detect the search event post-refresh using an Interaction to make the cancel button visible? Or is this a limitation of your Interaction Manager?
<script>
document.addEventListener("DOMContentLoaded", function () {
let searchForm = document.getElementById("form_5071"); // Get search form
let cancelDiv = document.getElementById("cancel"); // Get cancel div
// Check if search was previously triggered
if (localStorage.getItem("searchTriggered") === "true") {
cancelDiv.style.display = "block"; // Show cancel div after page refresh
}
if (searchForm && cancelDiv) {
searchForm.addEventListener("submit", function () {
localStorage.setItem("searchTriggered", "true"); // Store search state
});
}
// Hide cancel div and reset state when cancel button is clicked
let cancelButton = document.querySelector("#cancel a");
if (cancelButton) {
cancelButton.addEventListener("click", function () {
cancelDiv.style.display = "none"; // Hide cancel div
localStorage.removeItem("searchTriggered"); // Reset search state
});
}
});
</script>