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

fix(Carousel): pages calculation #2345

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

EdmundChaplin
Copy link

πŸ”— Linked issue

Resolves #2045

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Fixed the carousel pages calculation so that it no longer errors when the number of prop items is less than the number of calculated divisions.

The pages calculation in the carousel component returns a negative value when the number of items is less than the number of carousel divisions (calculated from the width of the carousel divided by the width of an item).

This causes the error RangeError: Invalid array length in the indicators template, as it is trying to run v-for="page in pages", where pages is negative.

The use case which first produced this issue was a carousel of recently viewed products. Initially, there is only 1 item in the carousel, however the items widths had been setup to display multiple items, as and when the user views more products.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

…e number of items is less than the number of divisions
@benjamincanac benjamincanac changed the title fix: carousel pages calculation fix(Carousel): pages calculation Oct 9, 2024
@benjamincanac benjamincanac merged commit 5cf24fa into nuxt:dev Oct 9, 2024
2 checks passed
@benjamincanac
Copy link
Member

Thanks! 😊

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

Successfully merging this pull request may close these issues.

Indicators causing bug in Carousel: "invalid array length"
2 participants