Skip to content

Commit

Permalink
Remove enableAccessibleFieldDOMStructure prop when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Sep 17, 2024
1 parent 7b1784d commit bce7e95
Show file tree
Hide file tree
Showing 47 changed files with 82 additions and 284 deletions.
10 changes: 2 additions & 8 deletions docs/data/date-pickers/custom-field/MaterialV7FieldWrapped.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ export default function MaterialV7FieldWrapped() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DemoContainer components={['DateField', 'DatePicker']}>
<DateField
enableAccessibleFieldDOMStructure
slots={{ textField: MyPickersTextField }}
/>
<DatePicker
enableAccessibleFieldDOMStructure
slots={{ textField: MyPickersTextField }}
/>
<DateField slots={{ textField: MyPickersTextField }} />
<DatePicker slots={{ textField: MyPickersTextField }} />
</DemoContainer>
</LocalizationProvider>
);
Expand Down
10 changes: 2 additions & 8 deletions docs/data/date-pickers/custom-field/MaterialV7FieldWrapped.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ export default function MaterialV7FieldWrapped() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DemoContainer components={['DateField', 'DatePicker']}>
<DateField
enableAccessibleFieldDOMStructure
slots={{ textField: MyPickersTextField }}
/>
<DatePicker
enableAccessibleFieldDOMStructure
slots={{ textField: MyPickersTextField }}
/>
<DateField slots={{ textField: MyPickersTextField }} />
<DatePicker slots={{ textField: MyPickersTextField }} />
</DemoContainer>
</LocalizationProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
<DateField
enableAccessibleFieldDOMStructure
slots={{ textField: MyPickersTextField }}
/>
<DatePicker
enableAccessibleFieldDOMStructure
slots={{ textField: MyPickersTextField }}
/>
<DateField slots={{ textField: MyPickersTextField }} />
<DatePicker slots={{ textField: MyPickersTextField }} />
2 changes: 1 addition & 1 deletion docs/data/date-pickers/fields/BasicV7DOMStructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function BasicV7DOMStructure() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DemoContainer components={['DateField']}>
<DateField label="Date Field" enableAccessibleFieldDOMStructure />
<DateField label="Date Field" />
</DemoContainer>
</LocalizationProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/date-pickers/fields/BasicV7DOMStructure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function BasicV7DOMStructure() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DemoContainer components={['DateField']}>
<DateField label="Date Field" enableAccessibleFieldDOMStructure />
<DateField label="Date Field" />
</DemoContainer>
</LocalizationProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<DateField label="Date Field" enableAccessibleFieldDOMStructure />
<DateField label="Date Field"/>
10 changes: 5 additions & 5 deletions docs/data/migration/migration-pickers-v7/migration-pickers-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ the field consumes some props (e.g: `shouldRespectLeadingZeros`) and forwards th
```js
<DatePicker
slotProps={{ field: { shouldRespectLeadingZeros: true } }}
enableAccessibleFieldDOMStructure
/>
enableAccessibleFieldDOMStructure={false}
/>
<DatePicker
slotProps={{ field: { shouldRespectLeadingZeros: true } }}
/>
Expand All @@ -106,8 +106,8 @@ the field consumes some props (e.g: `shouldRespectLeadingZeros`) and forwards th
```js
<DatePicker
slotProps={{ field: { size: 'small' } }}
enableAccessibleFieldDOMStructure
/>
enableAccessibleFieldDOMStructure={false}
/>
<DatePicker
slotProps={{ field: { size: 'small' } }}
/>
Expand All @@ -123,7 +123,7 @@ Both components below will render a small size UI:
```js
<DatePicker
slotProps={{ textField: { size: 'small' } }}
enableAccessibleFieldDOMStructure
enableAccessibleFieldDOMStructure={false}
/>
<DatePicker
slotProps={{ textField: { size: 'small' } }}
Expand Down
1 change: 0 additions & 1 deletion docs/src/modules/components/overview/Keyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ export default function Keyboard() {
onKeyUp={() => {
setSelectedKey(null);
}}
enableAccessibleFieldDOMStructure
onSelectedSectionsChange={(newSelectedSection) => {
selectedSection.current = newSelectedSection;
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('<DateRangePicker />', () => {
const originalMatchMedia = window.matchMedia;
window.matchMedia = stubMatchMedia(false);

render(<DateRangePicker enableAccessibleFieldDOMStructure />);
render(<DateRangePicker />);
fireEvent.click(getFieldInputRoot());
clock.runToLast();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('<DesktopDateRangePicker />', () => {
it('should scroll current month to the active selection when focusing appropriate field', () => {
render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
reduceAnimations
defaultValue={[adapterToUse.date('2019-05-19'), adapterToUse.date('2019-10-30')]}
/>,
Expand All @@ -49,10 +48,7 @@ describe('<DesktopDateRangePicker />', () => {

it(`should not crash when opening picker with invalid date value`, () => {
render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
defaultValue={[new Date(NaN), adapterToUse.date('2019-01-31')]}
/>,
<DesktopDateRangePicker defaultValue={[new Date(NaN), adapterToUse.date('2019-01-31')]} />,
);

openPicker({ type: 'date-range', variant: 'desktop', initialFocus: 'start' });
Expand All @@ -74,7 +70,6 @@ describe('<DesktopDateRangePicker />', () => {
<ThemeProvider theme={theme}>
<LocalizationProvider dateAdapter={AdapterClassToUse}>
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
// We set the variant to standard to avoid having the label rendered in two places.
slotProps={{
textField: {
Expand All @@ -94,10 +89,7 @@ describe('<DesktopDateRangePicker />', () => {
it('should add focused class to the field when it is focused', () => {
// test v7 behavior
const { unmount } = render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
slots={{ field: SingleInputDateRangeField }}
/>,
<DesktopDateRangePicker slots={{ field: SingleInputDateRangeField }} />,
);

const sectionsContainer = getFieldSectionsContainer();
Expand All @@ -119,11 +111,7 @@ describe('<DesktopDateRangePicker />', () => {
it('should render the input with a given `name` when `SingleInputDateRangeField` is used', () => {
// Test with v7 input
const { unmount } = render(
<DesktopDateRangePicker
name="test"
enableAccessibleFieldDOMStructure
slots={{ field: SingleInputDateRangeField }}
/>,
<DesktopDateRangePicker name="test" slots={{ field: SingleInputDateRangeField }} />,
);
expect(screen.getByRole<HTMLInputElement>('textbox', { hidden: true }).name).to.equal('test');

Expand All @@ -141,7 +129,6 @@ describe('<DesktopDateRangePicker />', () => {
const handleTouchStart = spy();
render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
open
slotProps={{
popper: {
Expand All @@ -167,7 +154,7 @@ describe('<DesktopDateRangePicker />', () => {
it('should open when clicking the start input', () => {
const onOpen = spy();

render(<DesktopDateRangePicker enableAccessibleFieldDOMStructure onOpen={onOpen} />);
render(<DesktopDateRangePicker onOpen={onOpen} />);

openPicker({ type: 'date-range', variant: 'desktop', initialFocus: 'start' });

Expand All @@ -178,7 +165,7 @@ describe('<DesktopDateRangePicker />', () => {
it('should open when clicking the end input', () => {
const onOpen = spy();

render(<DesktopDateRangePicker enableAccessibleFieldDOMStructure onOpen={onOpen} />);
render(<DesktopDateRangePicker onOpen={onOpen} />);

openPicker({ type: 'date-range', variant: 'desktop', initialFocus: 'end' });

Expand All @@ -190,7 +177,7 @@ describe('<DesktopDateRangePicker />', () => {
it(`should open when pressing "${key}" in the start input`, () => {
const onOpen = spy();

render(<DesktopDateRangePicker enableAccessibleFieldDOMStructure onOpen={onOpen} />);
render(<DesktopDateRangePicker onOpen={onOpen} />);

const startInput = getFieldSectionsContainer();
act(() => startInput.focus());
Expand All @@ -206,7 +193,7 @@ describe('<DesktopDateRangePicker />', () => {
it(`should open when pressing "${key}" in the end input`, () => {
const onOpen = spy();

render(<DesktopDateRangePicker enableAccessibleFieldDOMStructure onOpen={onOpen} />);
render(<DesktopDateRangePicker onOpen={onOpen} />);

const endInput = getFieldSectionsContainer(1);
act(() => endInput.focus());
Expand All @@ -229,7 +216,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand Down Expand Up @@ -272,7 +258,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand Down Expand Up @@ -307,7 +292,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onAccept={onAccept}
onClose={onClose}
defaultValue={defaultValue}
Expand Down Expand Up @@ -335,7 +319,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand Down Expand Up @@ -365,12 +348,7 @@ describe('<DesktopDateRangePicker />', () => {

render(
<div>
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
/>
<DesktopDateRangePicker onChange={onChange} onAccept={onAccept} onClose={onClose} />
<input id="test-id" />
</div>,
);
Expand Down Expand Up @@ -404,7 +382,6 @@ describe('<DesktopDateRangePicker />', () => {
render(
<div>
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand Down Expand Up @@ -443,14 +420,7 @@ describe('<DesktopDateRangePicker />', () => {
const onAccept = spy();
const onClose = spy();

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
/>,
);
render(<DesktopDateRangePicker onChange={onChange} onAccept={onAccept} onClose={onClose} />);

// Dismiss the picker
fireEvent.click(document.body);
Expand All @@ -471,12 +441,7 @@ describe('<DesktopDateRangePicker />', () => {

render(
<React.Fragment>
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
/>
<DesktopDateRangePicker onChange={onChange} onAccept={onAccept} onClose={onClose} />
<button type="button" id="test">
{' '}
focus me
Expand Down Expand Up @@ -507,7 +472,6 @@ describe('<DesktopDateRangePicker />', () => {
render(
<div>
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
defaultValue={defaultValue}
onChange={onChange}
onAccept={onAccept}
Expand Down Expand Up @@ -547,7 +511,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand All @@ -574,7 +537,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand Down Expand Up @@ -602,7 +564,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand All @@ -627,7 +588,6 @@ describe('<DesktopDateRangePicker />', () => {

render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
onChange={onChange}
onAccept={onAccept}
onClose={onClose}
Expand All @@ -648,7 +608,7 @@ describe('<DesktopDateRangePicker />', () => {

describe('disabled dates', () => {
it('should respect the disablePast prop', () => {
render(<DesktopDateRangePicker enableAccessibleFieldDOMStructure disablePast />);
render(<DesktopDateRangePicker disablePast />);

openPicker({ type: 'date-range', variant: 'desktop', initialFocus: 'start' });

Expand All @@ -660,7 +620,7 @@ describe('<DesktopDateRangePicker />', () => {
});

it('should respect the disableFuture prop', () => {
render(<DesktopDateRangePicker enableAccessibleFieldDOMStructure disableFuture />);
render(<DesktopDateRangePicker disableFuture />);

openPicker({ type: 'date-range', variant: 'desktop', initialFocus: 'start' });

Expand All @@ -672,12 +632,7 @@ describe('<DesktopDateRangePicker />', () => {
});

it('should respect the minDate prop', () => {
render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
minDate={adapterToUse.date('2018-01-15')}
/>,
);
render(<DesktopDateRangePicker minDate={adapterToUse.date('2018-01-15')} />);

openPicker({ type: 'date-range', variant: 'desktop', initialFocus: 'start' });

Expand All @@ -689,12 +644,7 @@ describe('<DesktopDateRangePicker />', () => {
});

it('should respect the maxDate prop', () => {
render(
<DesktopDateRangePicker
enableAccessibleFieldDOMStructure
maxDate={adapterToUse.date('2018-01-15')}
/>,
);
render(<DesktopDateRangePicker maxDate={adapterToUse.date('2018-01-15')} />);

openPicker({ type: 'date-range', variant: 'desktop', initialFocus: 'start' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('<DesktopDateRangePicker /> - Describes', () => {
views: ['day'],
}));

describeConformance(<DesktopDateRangePicker enableAccessibleFieldDOMStructure />, () => ({
describeConformance(<DesktopDateRangePicker />, () => ({
classes: {} as any,
render,
muiName: 'MuiDesktopDateRangePicker',
Expand Down
Loading

0 comments on commit bce7e95

Please sign in to comment.