Skip to content

Commit

Permalink
fix(RangeCalendar): data-selection-start not being applied on first s…
Browse files Browse the repository at this point in the history
…elect (#810)

* fix(RangeCalendar): data-selection-start not being applied on first click

* fix(RangeCalendar): adjust test to handle reset range
  • Loading branch information
epr3 committed Apr 2, 2024
1 parent d550024 commit 56519b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/radix-vue/src/RangeCalendar/RangeCalendar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('RangeCalendar', () => {
startValue = calendar.querySelector('[data-selection-start]')
endValue = calendar.querySelector('[data-selection-end]')

expect(startValue).not.toBeInTheDocument()
expect(startValue).toBeInTheDocument()
expect(endValue).not.toBeInTheDocument()

const seventhDayInMonth = getByTestId('date-1-7')
Expand Down
4 changes: 2 additions & 2 deletions packages/radix-vue/src/RangeCalendar/useRangeCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
)

const isSelectionStart = (date: DateValue) => {
if (!props.start.value || !props.end.value)
if (!props.start.value)
return false
return isSameDay(props.start.value, date)
}

const isSelectionEnd = (date: DateValue) => {
if (!props.end.value || !props.start.value)
if (!props.end.value)
return false
return isSameDay(props.end.value, date)
}
Expand Down

0 comments on commit 56519b4

Please sign in to comment.