Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "chore: support ID prop in Calendar",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions packages/react/etc/react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3007,6 +3007,7 @@ export interface ICalendarProps extends IBaseProps<ICalendar>, React_2.RefAttrib
firstWeekOfYear?: FirstWeekOfYear;
highlightCurrentMonth?: boolean;
highlightSelectedMonth?: boolean;
id?: string;
isDayPickerVisible?: boolean;
isMonthPickerVisible?: boolean;
maxDate?: Date;
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/components/Calendar/Calendar.base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export const CalendarBase: React.FunctionComponent<ICalendarProps> = React.forwa
minDate,
maxDate,
restrictedDates,
id,
className,
showCloseButton,
allFocusable,
Expand Down Expand Up @@ -326,6 +327,7 @@ export const CalendarBase: React.FunctionComponent<ICalendarProps> = React.forwa

return (
<div
id={id}
Copy link
Member

Choose a reason for hiding this comment

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

I think v7 CalendarBase never actually applied id to the div. The forwarded ref has the HTMLDivElement props, but not the ICalendarProps. I think we could add id to v8, but then ODSP would see an output change when moving to v8.

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked it before, and the ID does get passed through. Here's a demo

https://codepen.io/micahgodbolt/pen/PoeRpVo?editors=0111

ref={forwardedRef}
role="group"
aria-label={selectionAndTodayString}
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/components/Calendar/Calendar.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export interface ICalendarProps extends IBaseProps<ICalendar>, React.RefAttribut
*/
onDismiss?: () => void;

/**
* ID for the calendar
*/
id?: string;

/**
* Default value of the Calendar, if any
*/
Expand Down