From 3d48a7c711b879bfec62a1ff52c51ca9b7ec4d43 Mon Sep 17 00:00:00 2001 From: XieZongChen <46394163+amadeus711@users.noreply.github.com> Date: Sun, 27 Jun 2021 15:59:34 +0800 Subject: [PATCH] fix(carousel): fix navigate to current item (#302) * fix(carousel): fix carousel click triggering button bug * Apply suggestions from code review Co-authored-by: 07akioni <07akioni2@gmail.com> --- CHANGELOG.en-US.md | 1 + CHANGELOG.zh-CN.md | 1 + src/carousel/src/Carousel.tsx | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 96a5eeb0d..581ae038b 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -16,6 +16,7 @@ - Fix `n-date-picker` `n-provider` pass `date-locale` not work, closes [#250](https://github.com/TuSimple/naive-ui/issues/250). - Fix `n-input` clear button placeholder prevent clicking on actual component [#288](https://github.com/TuSimple/naive-ui/issues/288) +- Fix `n-carousel` click the at current item button, the component behaves abnormally. ## 2.14.0 (2021-06-23) diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index e45bd15ef..5f52d0e89 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -16,6 +16,7 @@ - 修复 `n-date-picker` `n-provider` 传递 `date-locale` 属性无效,关闭 [#250](https://github.com/TuSimple/naive-ui/issues/250) - Fix `n-input` clear button placeholder prevent clicking on actual component [#288](https://github.com/TuSimple/naive-ui/issues/288) +- 修复 `n-carousel` 点击当前页对应的控制按钮时,组件显示异常 ## 2.14.0 (2021-06-23) diff --git a/src/carousel/src/Carousel.tsx b/src/carousel/src/Carousel.tsx index fa8f66aab..9c6ef219a 100644 --- a/src/carousel/src/Carousel.tsx +++ b/src/carousel/src/Carousel.tsx @@ -60,8 +60,9 @@ export default defineComponent({ function setCurrent (value: number): void { if (lengthRef.value <= 1) return if (inTransition) return - inTransition = true const { value: current } = currentRef + if (value === current) return + inTransition = true if (current === 1 && value === lengthRef.value && value - current > 1) { currentRef.value-- } else if (