Need help with Custom Button Scroll and Closing a Modal via Elementor Static Block

This topic has 2 replies, 2 voices, and was last updated 1 day, 2 hours ago ago by Jack Richardson

  • Avatar: khurram virk
    khurram virk
    Participant
    March 2, 2026 at 09:34

    Dear Sir,

    Good Day To You.

    I am working on my Single Product pages using the XStore Single Product Builder and I need help achieving two specific button interactions.

    Issue 1: Smart Scroll to Specifications Table
    I have added a custom “View Technical Specifications” button in the product builder.

    Goal: When a user clicks this button, I want the page to smoothly scroll down and open the Product Description tab. If there is a

    inside the description, it should scroll exactly to that table. If there is no table, it should just stop at the top of the description tab.

    Sample Product: https://safeandsecureksa.com/product/dee-d-shaped-forged-chain-shackle-with-bolt-pin/

    Screenshot of Button: https://snipboard.io/yIcKUn.jpg

    Issue 2: Closing a Custom Popup using a Static Block Button
    Inside the product description table, some items have a “QUOTE” button.

    When clicked, this Quote button triggers a popup.

    The Setup: The popup window itself is created using a custom code plugin (it is not an Elementor popup). However, the form and content inside the popup are being pulled from an Elementor Static Block.

    The Problem: Inside this Static Block, there is an “ADD MORE PRODUCTS” button. I want this button to simply close the popup modal. I tried setting the button’s dynamic link tag to Elementor’s native “Close Popup” action, but it does not work because the parent window isn’t a native Elementor popup.

    Screenshot of Popup: https://snipboard.io/TGQV5S.jpg

    Screenshot of my Elementor setup: https://snipboard.io/IcW7KH.jpg

    Could you please provide the best native XStore approach or a custom JS snippet to achieve these two specific button behaviors?

    Thank you!

    1 Answer
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    March 2, 2026 at 11:44

    Hello @khurram virk,

    Please note that your requests concern additional customization rather than the correction of theme-related issues or bugs. Below, we have attached an example snippet that you can use in your child-theme/functions.php file (https://prnt.sc/tBMsCQn05tlP).

    add_action('wp_footer', function() { ?>
    	<script type="text/javascript">
    	(function () {
    		'use strict';
    
    		function smoothScrollTo(el) {
    			if (!el) return;
    
    			var y = el.getBoundingClientRect().top + window.pageYOffset;
    			window.scrollTo({ top: y, behavior: 'smooth' });
    		}
    
    		function handleClick(e) {
    			var button = e.target.closest('a.et_element.et_b_single-button[href^="#"]');
    			if (!button) return;
    
    			var hash = button.getAttribute('href'); // "#tab-description"
    			if (!hash || hash === '#') return;
    
    			var panel = document.querySelector(hash); // the actual tab panel
    			if (!panel) return;
    
    			var tabTitle = document.querySelector('.et-woocommerce-tab[aria-controls="' + panel.id + '"]');
    			var tabLink = tabTitle ? tabTitle.querySelector('a[aria-controls="' + panel.id + '"]') : null;
    
    			e.preventDefault();
    
    			if (tabTitle && tabTitle.classList.contains('active')) {
    				smoothScrollTo(panel);
    				return;
    			}
    
    			if (tabLink) {
    				tabLink.click();
    
    				setTimeout(function () {
    					smoothScrollTo(panel);
    				}, 100);
    
    				return;
    			}
    
    			smoothScrollTo(panel);
    		}
    
    		document.addEventListener('click', handleClick);
    	})();
    	</script>
    <?php }); 

    Frontend example of such implementation: https://gyazo.com/a37a0ac1646b972760089c7963f9e6b7

    Regarding the popup closing issue, we recommend recreating your popups using the default functionality of Elementor Popups (you can export and then import your Static block content https://elementor.com/help/how-to-duplicate-an-elementor-page/) and verifying whether they work correctly. Please note that this closing action will not apply to popups created with static blocks instead of Elementor Popups. Otherwise, you will need to add custom CSS classes to the buttons inside the popups and create custom JavaScript snippets to trigger the popup closing action.

    If you require further assistance, please provide the relevant URLs and wp-admin access details so that we can review the button settings and page content. Please, note that we provide our support according to the Envato privacy policy, so additional customization is out of our basic support scope.

    Best regards,
    Jack Richardson
    The 8Theme’s Team

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.