Product Slider Section Layout Issue - Dawn Theme

Topic summary

A user encountered navigation issues with a custom product slider section in the Dawn theme. The slider consistently jumped to the first collection instead of the intended one, and swipe arrows only controlled the first slider when multiple sections were present.

Initial Problems:

  • Slider navigation targeting wrong collection
  • Arrow controls affecting only first section
  • Products not displaying in 3rd and 4th sections
  • Maximum of 20 products showing across all sections, with repetition afterward

Solutions Provided:

Two community members offered fixes:

  • ThePrimeWeb provided updated HTML/Liquid code with modified slider structure
  • MichalKopec suggested rewriting the nextClickHandler and prevClickHandler JavaScript functions to properly traverse parent nodes and target the correct slider element

Resolution:

After troubleshooting (including addressing missing products and investigating potential code conflicts), ThePrimeWeb provided a final code revision with a key change: removing all_products[] wrapper from the product assignment ({% assign product = block.settings.product_item %}). The user confirmed this resolved all issues.

Status: Resolved successfully

Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

Hello,

When I attempt to navigate to this particular slider, it consistently slides to the first slider of the collection instead of the intended slider. Could you please review the code to address this issue?

Additionally, it seems that the swipe arrow functionality only moves the first collection slider within the section, neglecting the others

https://060ef5-5.myshopify.com/


    

        ## {{ section.settings.title | escape }}
    

    
       

          {% for block in section.blocks %}
              {% assign product = all_products[block.settings.product_item] %}
              

                
                    
                    {% comment %}
                               

{{ product.title }}

                                

{{ product.price | money }}

                    {% endcomment %}
                
              

          {% endfor %}
       

        
            
        
        
            
        
    

  

{% schema %}
{
  "name": "Products slider",
  "settings": [
    {
      "type": "range",
      "id": "navigation_amount",
      "min": 2,
      "max": 6,
      "step": 1,
      "default": 6,
      "label": "Change the number of cards in view"
    },
    {
      "type": "color",
      "id": "navigation_color",
      "label": "Change color of the pagination|navigation|scrollbar"
    },
    {
      "type": "text",
      "id": "title",
      "default": "Products slider",
      "label": "t:sections.featured-collection.settings.title.label"
    }
  ] ,
    "blocks": [
    {
        "type": "card",
        "name": "Product card",
        "settings": [
          {
            "type": "product",
            "id": "product_item",
            "label": "Choose the product you want to displayed"
          }
        ]
    }
  ] ,
  "presets": [
    {
      "name": "Product slider",
      "category":"Custom"
    }
  ]
}
{% endschema %}

Hey @Charlo-007 ,

Replace the code with this.


    

        ## {{ section.settings.title | escape }}
    

    
       

          {% for block in section.blocks %}
              {% assign product = all_products[block.settings.product_item] %}
              

                
                    
                    {% comment %}
                               

{{ product.title }}

                                

{{ product.price | money }}

                    {% endcomment %}
                
              

          {% endfor %}
       

        
            
        
        
            
        
    

  

{% schema %}
{
  "name": "Products slider",
  "settings": [
    {
      "type": "range",
      "id": "navigation_amount",
      "min": 2,
      "max": 6,
      "step": 1,
      "default": 6,
      "label": "Change the number of cards in view"
    },
    {
      "type": "color",
      "id": "navigation_color",
      "label": "Change color of the pagination|navigation|scrollbar"
    },
    {
      "type": "text",
      "id": "title",
      "default": "Products slider",
      "label": "t:sections.featured-collection.settings.title.label"
    }
  ] ,
    "blocks": [
    {
        "type": "card",
        "name": "Product card",
        "settings": [
          {
            "type": "product",
            "id": "product_item",
            "label": "Choose the product you want to displayed"
          }
        ]
    }
  ] ,
  "presets": [
    {
      "name": "Product slider",
      "category":"Custom"
    }
  ]
}
{% endschema %}

Hello, you will need to change the behaviour of your nextClickHandler and prevClickHandler:

function nextClickHandler() {
    const source = event.target || event.srcElement;
    var p = source.parentNode;
    while (!p.classList.contains("dawn-product-slider")) {
        var o = p;
        p = o.parentNode;
    }
    const el = p.querySelector("#slider");
        
    el.scrollTo({
        top: 0,
        left: el.scrollLeft + 250,
        behavior: 'smooth'
    });
}

function prevClickHandler() {
    const source = event.target || event.srcElement;
    var p = source.parentNode;
    while (!p.classList.contains("dawn-product-slider")) {
        var o = p;
        p = o.parentNode;
    }
    const el = p.querySelector("#slider");

    el.scrollTo({
        top: 0,
        left: el.scrollLeft - 250,
        behavior: 'smooth'
    });
}

Kind Regards,

Michal Kopec

1 Like

@ThePrimeWeb Could you please review the code again to address this issue why are products not showing in the 3rd and 4th sections? https://060ef5-5.myshopify.com/

Because you didn’t add products?

1 Like

addded @ThePrimeWeb

pls check ss @ThePrimeWeb

@ThePrimeWeb

You would have to check on your end what you did with the theme, maybe some other code you wrote is breaking this one. Because when I try to have 4 or more of these sections it works fine for me, there’s nothing odd with the code.

The error you are showing has no impact. It’s just a warning, not an error. Just saying that img_url will be removed in the future, so you might want to switch to image_url. But in the meantime it is working.

1 Like

@ThePrimeWeb the slider stops displaying products altogether, showing only a maximum of 20 products across all sections where it’s implemented. And start repeating the same product after 20 products.

Request to Check Product Slider Code: ( Product Slider is not working when I use it multiple times)
https://community.shopify.com/c/shopify-design/request-to-check-product-slider-code-product-slider-is-not/m-p/2549441#M669599

Hey @Charlo-007 ,

Try this. Remove the sections and add them again from scratch.


    

        ## {{ section.settings.title | escape }}
    

    
       

          {% for block in section.blocks %}
              {% assign product = block.settings.product_item %}
              

                
                    
                    {% comment %}
                               

{{ product.title }}

                                

{{ product.price | money }}

                    {% endcomment %}
                
              

          {% endfor %}
       

        
            
        
        
            
        
    

  

{% schema %}
{
  "name": "Products slider",
  "settings": [
    {
      "type": "range",
      "id": "navigation_amount",
      "min": 2,
      "max": 6,
      "step": 1,
      "default": 6,
      "label": "Change the number of cards in view"
    },
    {
      "type": "color",
      "id": "navigation_color",
      "label": "Change color of the pagination|navigation|scrollbar"
    },
    {
      "type": "text",
      "id": "title",
      "default": "Products slider",
      "label": "t:sections.featured-collection.settings.title.label"
    }
  ] ,
    "blocks": [
    {
        "type": "card",
        "name": "Product card",
        "settings": [
          {
            "type": "product",
            "id": "product_item",
            "label": "Choose the product you want to displayed"
          }
        ]
    }
  ] ,
  "presets": [
    {
      "name": "Product slider",
      "category":"Custom"
    }
  ]
}
{% endschema %}

Awesome :heart_eyes: Made my day @ThePrimeWeb