Skip to content

Commit 1e8c02e

Browse files
authored
fix: show calendar header in s2 dialog (#8621)
* clear context * add story for testing * Revert "add story for testing" This reverts commit 680ddcf. * add fix to range calendar
1 parent 863ac42 commit 1e8c02e

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

packages/@react-spectrum/s2/src/Calendar.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {ActionButton, Header, Heading, pressScale} from './';
13+
import {ActionButton, Header, HeaderContext, Heading, HeadingContext, pressScale} from './';
1414
import {
1515
Calendar as AriaCalendar,
1616
CalendarCell as AriaCalendarCell,
@@ -27,6 +27,7 @@ import {
2727
CalendarStateContext,
2828
ContextValue,
2929
DateValue,
30+
Provider,
3031
RangeCalendarState,
3132
RangeCalendarStateContext,
3233
Text
@@ -304,11 +305,17 @@ export const Calendar = /*#__PURE__*/ (forwardRef as forwardRefType)(function Ca
304305
{({isInvalid, isDisabled}) => {
305306
return (
306307
<>
307-
<Header styles={headerStyles}>
308-
<CalendarButton slot="previous"><ChevronLeftIcon /></CalendarButton>
309-
<CalendarHeading />
310-
<CalendarButton slot="next"><ChevronRightIcon /></CalendarButton>
311-
</Header>
308+
<Provider
309+
values={[
310+
[HeaderContext, null],
311+
[HeadingContext, null]
312+
]}>
313+
<Header styles={headerStyles}>
314+
<CalendarButton slot="previous"><ChevronLeftIcon /></CalendarButton>
315+
<CalendarHeading />
316+
<CalendarButton slot="next"><ChevronRightIcon /></CalendarButton>
317+
</Header>
318+
</Provider>
312319
<div
313320
className={style({
314321
display: 'flex',

packages/@react-spectrum/s2/src/RangeCalendar.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
RangeCalendarProps as AriaRangeCalendarProps,
1616
ContextValue,
1717
DateValue,
18+
Provider,
1819
Text
1920
} from 'react-aria-components';
2021
import {CalendarButton, CalendarGrid, CalendarHeading} from './Calendar';
@@ -23,7 +24,7 @@ import ChevronRightIcon from '../s2wf-icons/S2_Icon_ChevronRight_20_N.svg';
2324
import {createContext, ForwardedRef, forwardRef, ReactNode} from 'react';
2425
import {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';
2526
import {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
26-
import {Header} from './';
27+
import {Header, HeaderContext, HeadingContext} from './';
2728
import {helpTextStyles} from './Field';
2829
// @ts-ignore
2930
import intlMessages from '../intl/*.json';
@@ -85,11 +86,17 @@ export const RangeCalendar = /*#__PURE__*/ (forwardRef as forwardRefType)(functi
8586
{({isInvalid, isDisabled}) => {
8687
return (
8788
<>
88-
<Header styles={headerStyles}>
89-
<CalendarButton slot="previous"><ChevronLeftIcon /></CalendarButton>
90-
<CalendarHeading />
91-
<CalendarButton slot="next"><ChevronRightIcon /></CalendarButton>
92-
</Header>
89+
<Provider
90+
values={[
91+
[HeaderContext, null],
92+
[HeadingContext, null]
93+
]}>
94+
<Header styles={headerStyles}>
95+
<CalendarButton slot="previous"><ChevronLeftIcon /></CalendarButton>
96+
<CalendarHeading />
97+
<CalendarButton slot="next"><ChevronRightIcon /></CalendarButton>
98+
</Header>
99+
</Provider>
93100
<div
94101
className={style({
95102
display: 'flex',

0 commit comments

Comments
 (0)