diff --git a/change/@fluentui-react-5e1a9878-e11f-4ae1-9cbf-71a0a7d296b9.json b/change/@fluentui-react-5e1a9878-e11f-4ae1-9cbf-71a0a7d296b9.json new file mode 100644 index 0000000000000..313472b2b8ccb --- /dev/null +++ b/change/@fluentui-react-5e1a9878-e11f-4ae1-9cbf-71a0a7d296b9.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: keep Calendar day cells from expanding with external table cell padding", + "packageName": "@fluentui/react", + "email": "kirtiar15502@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.styles.ts b/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.styles.ts index aecc4de0c36be..656ee2377c84c 100644 --- a/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.styles.ts +++ b/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.styles.ts @@ -103,6 +103,7 @@ export const styles = (props: ICalendarDayGridStyleProps): ICalendarDayGridStyle { margin: 0, padding: 0, + boxSizing: 'border-box', width: 28, height: 28, lineHeight: 28, @@ -112,6 +113,9 @@ export const styles = (props: ICalendarDayGridStyleProps): ICalendarDayGridStyle cursor: 'pointer', position: 'relative', selectors: { + '&&': { + padding: 0, + }, [HighContrastSelector]: { color: 'WindowText', backgroundColor: 'transparent', diff --git a/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.test.tsx b/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.test.tsx index 50cf84f156e36..8b4dd4948d9e1 100644 --- a/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.test.tsx +++ b/packages/react/src/components/CalendarDayGrid/CalendarDayGrid.test.tsx @@ -2,6 +2,8 @@ import { CalendarDayGrid } from './CalendarDayGrid'; import { defaultCalendarStrings } from '../Calendar/index'; import { DateRangeType, DayOfWeek, FirstWeekOfYear } from '@fluentui/date-time-utilities'; import { isConformant } from '../../common/isConformant'; +import { getTheme } from '../../Styling'; +import { styles } from './CalendarDayGrid.styles'; describe('CalendarDayGrid', () => { isConformant({ @@ -31,4 +33,22 @@ describe('CalendarDayGrid', () => { 'component-has-root-ref', ], }); + + it('keeps day cells from expanding under external table cell padding', () => { + const calendarStyles = styles({ + theme: getTheme(), + dateRangeType: DateRangeType.Day, + }); + + expect(calendarStyles.dayCell).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + boxSizing: 'border-box', + selectors: expect.objectContaining({ + '&&': { padding: 0 }, + }), + }), + ]), + ); + }); });