Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

id attribute in bs carousel on 5.3.2 doesn't accept numeric values #39581

Open
3 tasks done
KOT-OPET opened this issue Jan 12, 2024 · 4 comments
Open
3 tasks done

id attribute in bs carousel on 5.3.2 doesn't accept numeric values #39581

KOT-OPET opened this issue Jan 12, 2024 · 4 comments
Assignees
Labels

Comments

@KOT-OPET
Copy link

KOT-OPET commented Jan 12, 2024

Prerequisites

Describe the issue

I have a following shortcode in my project:

<!-- Carousel folder. Makes a carousel with every image inside the folder you've given as an inner argument-->

{{ $allImages := $.Page.Resources.ByType "image" }}
{{ $imagesInFolder := $allImages.Match (printf "%s/*" .Inner) }}
{{ $carouselFID := .Get "id" | default "tigidik" }}

<div id="{{ $carouselFID }}" class="carousel carousel-dark slide">
    
    <div class="carousel-indicators" style="margin-bottom: -1rem !important;">

        {{ range $index, $img := $imagesInFolder }}
            <button type="button" data-bs-target="#{{ $carouselFID }}" data-bs-slide-to="{{ $index }}" {{ if eq $index 0 }}class="active" aria-current="true"{{ end }} aria-label="Slide {{ add $index 1 }}"></button>
        {{ end }}
        
    </div>
    <div class="carousel-inner">
        {{ range $index, $img := $imagesInFolder }}
             {{ $img := $img.Resize "1200x q100 Lanczos" }}
             {{ $img := $img.Fill "1200x900 q85 Lanczos" }} <!-- scaling and cropping to fit 1200x900 while maintaining original proportions -->
            <div class="carousel-item {{ if eq $index 0 }}active{{ end }}">
                <img src="{{ $img.RelPermalink }}" class="d-block w-100" loading="lazy" alt="carousel is broken">
                <p class="dot-cs">
                    <b><a href="{{ $img }}">·&nbsp;</a></b>
                </p>
            </div>
        {{ end }}
    </div>
    <button class="carousel-control-prev" type="button" data-bs-target="#{{ $carouselFID }}" data-bs-slide="prev" style="left: -30px !important;">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="visually-hidden">Previous</span>
    </button>
    <button class="carousel-control-next" type="button" data-bs-target="#{{ $carouselFID }}" data-bs-slide="next" style="right: -30px !important;">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="visually-hidden">Next</span>
    </button>
</div>

This is a pretty much default bootstrap carousel with a bit of hugo html templating and custom styles.

After updating from 5.3.1 to 5.3.2 all my carousels stopped working. Buttons have become unresponsive.

I think I found a bug. Turns out, the carousel stops working if you assign a numeric value to div id= attribute. All my ids are numeric, so basically my whole website is broken on the 5.3.2 version. However, it worked on 5.3.1.

I checked it with codepen, and you can see a test case below.

<!-- in bootstrap 5.3.2 numeric id (666) breaks the carousel -->

<div id="666" class="carousel carousel-dark slide">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#666" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
    <button type="button" data-bs-target="#666" data-bs-slide-to="1" aria-label="Slide 2"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="..." class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="..." class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="..." class="d-block w-100" alt="...">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#666" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#666" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

What operating system(s) are you seeing the problem on?

macOS

What browser(s) are you seeing the problem on?

Safari

What version of Bootstrap are you using?

5.3.2

@CyrilKrylatov
Copy link

Isn't that because HTML specs says that an ID should begin with a letter? https://www.w3.org/TR/html401/types.html#type-name

@KOT-OPET
Copy link
Author

thank you! I discovered it too after I've filled the issue. So - my bad, I guess?

Still, the inconsistent behaviour of Bootstrap is confusing.

@louismaximepiton
Copy link
Member

Hey,

Are we asked to do something here ? I can't see how to handle it properly ? Should we mention it in the migration guide or something ? Or maybe we can safely close this issue ?

@KOT-OPET
Copy link
Author

KOT-OPET commented Jan 22, 2024

It's up to you to decide. I'm not a competent person.

I think it's worth to be mentioned in a changelog for the last version, because this is where I've checked if the behaviour was changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants