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): trigger incorrect current-index value on arrow button click with single image #5141

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fix `n-time-picker` formatting (format="HH: mm: ss. SSS") preventing modification of milliseconds in the edit box, closes [#5224](https://github.com/tusen-ai/naive-ui/issues/5224).
- Fix `n-notification` notification clips out of screen when screen width is less than 400px wide.
- Fix `n-carousel` transition effect incorrect when using the `slide` effect in loop mode with only two elements, closes [#4323](https://github.com/tusen-ai/naive-ui/issues/4323).
- Fix `n-carousel` trigger incorrect `current-index` value on arrow button click with single image, closes [#5130](https://github.com/tusen-ai/naive-ui/issues/5130).

### Features

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- 修复 `n-time-picker` 时间选择器格式化(`format="HH:mm:ss.SSS"`)后无法在编辑框内修改毫秒数的问题,关闭 [#5224](https://github.com/tusen-ai/naive-ui/issues/5224)
- 修复 `n-notification` 通知在屏幕宽度小于 400px 的时候溢出屏幕
- 修复 `n-carousel` 在只有两个元素时,过渡效果为 `slide` 且循环播放时过渡效果有问题,关闭 [#4323](https://github.com/tusen-ai/naive-ui/issues/4323)
- 修复 `n-carousel` 在只有一张图片时点击箭头切换按钮触发的 `current-index` 值不正确,关闭 [#5130](https://github.com/tusen-ai/naive-ui/issues/5130)

### Features

Expand Down
6 changes: 5 additions & 1 deletion src/carousel/src/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ export default defineComponent({
const duplicatedableRef = computed(
// duplicate the copy operation in `slide` mode,
// because only its DOM is sequence layout
() => props.loop && props.slidesPerView === 1 && sequenceLayoutRef.value
() =>
props.loop &&
props.slidesPerView === 1 &&
sequenceLayoutRef.value &&
totalViewRef.value > 1
)
// user wants to control the transition animation
const userWantsControlRef = computed(() => props.effect === 'custom')
Expand Down
Loading