Skip to content

Commit

Permalink
fix(calendarcard): 直接抛出ondayclick (#2150)
Browse files Browse the repository at this point in the history
* fix(calendarcard):  直接抛出ondayclick

* test: 由于去掉了事件触发的校验逻辑,所以需要更新单测
  • Loading branch information
oasis-cloud authored Apr 3, 2024
1 parent 48ecd0f commit 8b7d34c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/packages/calendarcard/__tests__/calendarcard.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('test onChange & onDayClick & onPageChange', async () => {

const nextDays = container.querySelectorAll('.nut-calendarcard-day.next')
fireEvent.click(nextDays[0])
expect(onDayClick).toHaveBeenCalledTimes(3)
expect(onDayClick).toHaveBeenCalledTimes(4)
expect(onPageChange).toHaveBeenCalledTimes(1)
})

Expand Down Expand Up @@ -160,9 +160,9 @@ test('test disableDay', async () => {
'.nut-calendarcard-day.current'
)
fireEvent.click(currentDays[22]) // 0123 disabled
expect(onDayClick).toHaveBeenCalledTimes(0)
fireEvent.click(currentDays[25]) // 0126
expect(onDayClick).toHaveBeenCalledTimes(1)
fireEvent.click(currentDays[25]) // 0126
expect(onDayClick).toHaveBeenCalledTimes(2)
})

test('test ref methods', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/calendarcard/calendarcard.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ export const CalendarCard = React.forwardRef<
})

const handleDayClick = (day: CalendarCardDay) => {
onDayClick?.(day)
if (day.type === 'prev' || day.type === 'next' || isDisable(day)) {
return
}
onDayClick?.(day)
switch (type) {
case 'single': {
if (innerValue[0] && isSameDay(innerValue[0], day)) {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/calendarcard/calendarcard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ export const CalendarCard = React.forwardRef<
})

const handleDayClick = (day: CalendarCardDay) => {
onDayClick?.(day)
if (day.type === 'prev' || day.type === 'next' || isDisable(day)) {
return
}
onDayClick?.(day)
switch (type) {
case 'single': {
if (innerValue[0] && isSameDay(innerValue[0], day)) {
Expand Down

0 comments on commit 8b7d34c

Please sign in to comment.