question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Carousel control crashes on addition without initial items

See original GitHub issue

Describe the bug The carousel control crashes when it has no items initially and one adds items afterwards.

To Reproduce

  1. Add a carousel without any initial items
  2. Add an item (e.g. via code) once the view has been initialised.
  3. Crashes with an Out-of-bounds exception

Expected behavior No crash.

Additional context Debugging shows that Carousel.UpdateItemsPosition() is crashing once it tries to use the PageIndex, which is -1 at that point and therefore of course out-of-bounds.

Possible fix is to update the PageIndex to an in-bounds range value when an item is added.

private void UpdateItemsPosition()
{
    if (!CheckNull() || !_appliedTemplate || Items.Count == 0)
        return;

    if (PageIndex == -1) // Fixes the crash
    {
         PageIndex = 0;
    }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SamirKharchicommented, Oct 21, 2021

Hi guys!

sorry for the delay (had tons of work crashing on me after holidays, then it slipped my mind). I had the time yesterday to strip down our crashing code base and once I have stripped it down, the crash is not reproducable anymore I’m afraid. However, in our full blown code it still does crash. It might be a threading issue on our side or something to do with Prism (which we are using) I guess, because I cannot reproduce it on a clean project or the demo project of HandyControl either.

I keep it in our version of HandyControl but it probably is not a necessary fix. So rry for keeping this pending for so long.

0reactions
ghost1372commented, Oct 19, 2021

@SamirKharchi Are you back?😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap-3 Carousel freezes after some clicks
I tried to load jquery first then bootstrap.js. But the freezes still occurs. It should be running without problem and always responsive to ......
Read more >
10 Most Common Bootstrap Mistakes That Developers Make
These include Typography, Tables, Forms, Buttons, Glyphicons, Dropdowns, Buttons and Input Groups, Navigation, Pagination, Labels and Badges, Alerts, Progress ...
Read more >
Carousel not working in Bootstrap 5 (SOLVED) - YouTube
Professional CSS Course: https://www.udemy.com/course/professional-css/?referralCode=4C3C08E82629E6B15752 Professional JavaScript Course: ...
Read more >
Carousel · Bootstrap
The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It...
Read more >
Carousel with MotionLayout
Carousel is a motion helper object to easily build custom "carousel" views – showing a list of elements that a user can skim...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found