Carousel control crashes on addition without initial items
See original GitHub issueDescribe the bug The carousel control crashes when it has no items initially and one adds items afterwards.
To Reproduce
- Add a carousel without any initial items
- Add an item (e.g. via code) once the view has been initialised.
- 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:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@SamirKharchi Are you back?😅