Skip to content

Commit

Permalink
fix(comp:carousel): pre and next arrow should hide when item count is…
Browse files Browse the repository at this point in the history
… 0 (#1871)
  • Loading branch information
sallerli1 committed Apr 8, 2024
1 parent 49eb4ea commit e8a6d6e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 2 additions & 5 deletions packages/components/carousel/__tests__/carousel.spec.ts
Expand Up @@ -107,11 +107,8 @@ describe('Carousel', () => {
},
})

await wrapper.find('.ix-carousel-arrow-prev').trigger('click')
expect(onChange).toHaveBeenCalledTimes(0)

await wrapper.find('.ix-carousel-arrow-next').trigger('click')
expect(onChange).toHaveBeenCalledTimes(0)
expect(wrapper.find('.ix-carousel-arrow-prev').exists()).toBeFalsy()
expect(wrapper.find('.ix-carousel-arrow-next').exists()).toBeFalsy()
})

test('slot dot work', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/carousel/src/Carousel.tsx
Expand Up @@ -191,7 +191,7 @@ export default defineComponent({
))}
</div>
</div>
{mergedShowArrow.value && (
{mergedShowArrow.value && children.length > 1 && (
<>
<div key="__arrow-prev" class={`${prefixCls}-arrow ${prefixCls}-arrow-prev`} onClick={prev}>
{slots.arrow ? slots.arrow({ type: 'prev' }) : <IxIcon name="left-filled" />}
Expand Down
5 changes: 5 additions & 0 deletions packages/components/carousel/src/composables/useStrategy.ts
Expand Up @@ -88,6 +88,11 @@ export function useStrategy(
}

const { from, to } = getBoundary(activeIndex.value, index, length)

if (from === to) {
return
}

nextIndex.value = index
runningIndex.value = to

Expand Down

0 comments on commit e8a6d6e

Please sign in to comment.