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

Calendar calendar state context set value can not set null value #6030

Conversation

psywalker
Copy link
Contributor

@psywalker psywalker commented Mar 9, 2024

Closes #6006

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

  1. Open the calendar page where the Footer component is inserted (Story link)
  2. Select an arbitrary date in the calendar.
  3. Click the "Reset value" button in the Footer component.
  4. Make sure that after clicking the button, the selected date is reset, and no date is displayed in the calendar as selected.
  5. Check that pressing the "Reset value" button again after selecting a new date resets the selection again.
Monosnap.screencast.2024-03-09.15-39-42.mp4

@psywalker psywalker marked this pull request as draft March 10, 2024 13:10
@psywalker psywalker force-pushed the calendar-CalendarStateContext-setValue-can-not-set-null-value branch from 5d7b5ba to 36f024a Compare March 10, 2024 13:49
@psywalker psywalker force-pushed the calendar-CalendarStateContext-setValue-can-not-set-null-value branch from 36f024a to 6e4d36b Compare March 10, 2024 13:56
@psywalker psywalker marked this pull request as ready for review March 18, 2024 08:58
@LFDanLu
Copy link
Member

LFDanLu commented Mar 18, 2024

GET_BUILD

@rspbot
Copy link

rspbot commented Mar 18, 2024

@rspbot
Copy link

rspbot commented Mar 18, 2024

## API Changes

unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }

@react-stately/calendar

CalendarState

 CalendarState {
   focusNextDay: () => void
   focusNextPage: () => void
   focusNextRow: () => void
   focusNextSection: (boolean) => void
   focusPreviousDay: () => void
   focusPreviousPage: () => void
   focusPreviousRow: () => void
   focusPreviousSection: (boolean) => void
   focusSectionEnd: () => void
   focusSectionStart: () => void
   focusedDate: CalendarDate
   getDatesInWeek: (number, CalendarDate) => Array<CalendarDate | null>
   isCellDisabled: (CalendarDate) => boolean
   isCellFocused: (CalendarDate) => boolean
   isCellUnavailable: (CalendarDate) => boolean
   isDisabled: boolean
   isFocused: boolean
   isInvalid: (CalendarDate) => boolean
   isNextVisibleRangeInvalid: () => boolean
   isPreviousVisibleRangeInvalid: () => boolean
   isReadOnly: boolean
   isSelected: (CalendarDate) => boolean
   isValueInvalid: boolean
   maxValue?: DateValue
   minValue?: DateValue
   selectDate: (CalendarDate) => void
   selectFocusedDate: () => void
   setFocused: (boolean) => void
   setFocusedDate: (CalendarDate) => void
-  setValue: (CalendarDate) => void
+  setValue: (CalendarDate | null) => void
   timeZone: string
-  value: CalendarDate
+  value: CalendarDate | null
   visibleRange: RangeValue<CalendarDate>
 }

LFDanLu
LFDanLu previously approved these changes Mar 19, 2024
Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR!

@snowystinger
Copy link
Member

Looks really good, just a couple small things and then I think it's good to go :)

@psywalker
Copy link
Contributor Author

@LFDanLu, Hello! Has everything stopped here? :(

@dannify
Copy link
Member

dannify commented Apr 4, 2024

hey @psywalker
It looks like there are some left over review suggestions that need to be incorporated into the PR. After those are cleaned up, we can pick this up again. Thanks!

@LFDanLu LFDanLu merged commit b2d25ef into adobe:main Apr 8, 2024
25 checks passed
@andredewaard
Copy link

Can we also add this to the date range picker?

@LFDanLu
Copy link
Member

LFDanLu commented Oct 16, 2024

@andredewaard mind expanding a bit on the ask here? DateRangePicker should already support something like this via its own context: https://react-spectrum.adobe.com/react-aria/DateRangePicker.html#state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calendar's controlled value prop (in onChange) and setValue() from CalendarStateContext can't be set to null
6 participants