Skip to content

Commit 0a2d5b7

Browse files
authored
fix: Propagate isDisabled prop from DateRangePicker to popover Button (#5413)
1 parent 22aa113 commit 0a2d5b7

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/@react-aria/datepicker/src/useDateRangePicker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
158158
'aria-labelledby': `${buttonId} ${labelledBy}`,
159159
'aria-describedby': ariaDescribedBy,
160160
'aria-expanded': state.isOpen,
161+
isDisabled: props.isDisabled || props.isReadOnly,
161162
onPress: () => state.setOpen(true)
162163
},
163164
dialogProps: {

packages/@react-spectrum/datepicker/src/DateRangePicker.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ function DateRangePicker<T extends DateValue>(props: SpectrumDateRangePickerProp
4444
let {
4545
isQuiet,
4646
isDisabled,
47-
isReadOnly,
4847
autoFocus,
4948
placeholderValue,
5049
maxVisibleMonths = 1,
@@ -170,8 +169,7 @@ function DateRangePicker<T extends DateValue>(props: SpectrumDateRangePickerProp
170169
{...mergeProps(buttonProps, focusPropsButton)}
171170
UNSAFE_className={classNames(styles, 'spectrum-FieldButton')}
172171
isQuiet={isQuiet}
173-
validationState={validationState}
174-
isDisabled={isDisabled || isReadOnly}>
172+
validationState={validationState}>
175173
<CalendarIcon />
176174
</FieldButton>
177175
<Dialog UNSAFE_className={classNames(datepickerStyles, 'react-spectrum-Datepicker-dialog')} {...dialogProps}>

packages/react-aria-components/test/DateRangePicker.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,19 @@ describe('DateRangePicker', () => {
279279
await user.click(selected.nextSibling.children[1]);
280280
expect(dialog).toBeInTheDocument();
281281
});
282+
283+
it('should disable button and date input when DatePicker is disabled', () => {
284+
let {getByRole} = render(<TestDateRangePicker isDisabled />);
285+
286+
let button = getByRole('button');
287+
expect(button).toBeDisabled();
288+
289+
let group = getByRole('group');
290+
expect(group).toHaveAttribute('aria-disabled', 'true');
291+
292+
let spinbuttons = within(group).getAllByRole('spinbutton');
293+
for (let spinbutton of spinbuttons) {
294+
expect(spinbutton).toHaveAttribute('aria-disabled', 'true');
295+
}
296+
});
282297
});

0 commit comments

Comments
 (0)