Skip to content
Draft
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
16 changes: 0 additions & 16 deletions docs/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,6 @@ function useProductData(pageProps: { versions: VersionEntry[] }) {
};
}

// TODO: 'core' is a productCategoryId, not a productId — this branch may be dead code.
if ((productId as string) === 'core') {
return {
metadata: '',
name: 'MUI Core',
logo: MuiLogomarkIcon,
logoSvg: muiSvgLogomarkString,
wordmarkSvg: muiSvgLogotypeString,
versions: buildProductVersions(
fetchedVersions,
'material-ui',
`v${materialPkgJson.version}`,
),
};
}

if (productId === 'docs-infra') {
return {
metadata: '',
Expand Down
17 changes: 8 additions & 9 deletions packages-internal/core-docs/src/MarkdownDocs/MarkdownElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -860,16 +860,15 @@ export const MarkdownElement = React.forwardRef<HTMLDivElement, MarkdownElementP
}
}, []);

const more: React.ComponentProps<typeof Root> = {};

if (typeof renderedMarkdown === 'string') {
// workaround for https://github.com/react/react/issues/17170
// otherwise we could just set `dangerouslySetInnerHTML={undefined}`
more.dangerouslySetInnerHTML = { __html: renderedMarkdown };
}

return (
<Root className={clsx('markdown-body', className)} {...more} {...other} ref={handleRef} />
<Root
className={clsx('markdown-body', className)}
dangerouslySetInnerHTML={
typeof renderedMarkdown === 'string' ? { __html: renderedMarkdown } : undefined
}
{...other}
ref={handleRef}
/>
);
},
);
95 changes: 44 additions & 51 deletions packages/mui-material/src/Autocomplete/Autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,38 +372,35 @@ describe('<Autocomplete />', () => {
});

// https://github.com/mui/material-ui/issues/34998
it.skipIf(isJsdom())(
'should scroll the listbox to the top when keyboard highlight wraps around after the last item is highlighted',
function test() {
render(
<Autocomplete
open
options={['one', 'two', 'three', 'four', 'five']}
renderInput={(params) => <TextField {...params} />}
slotProps={{ listbox: { style: { padding: 0, maxHeight: '100px' } } }}
slots={{
popper: (props) => {
const { disablePortal, anchorEl, open, ...other } = props;
return <Box {...other} />;
},
}}
/>,
);
const textbox = screen.getByRole('combobox');
act(() => {
textbox.focus();
});
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
it('should scroll the listbox to the top when keyboard highlight wraps around after the last item is highlighted', function test() {
render(
<Autocomplete
open
options={['one', 'two', 'three', 'four', 'five']}
renderInput={(params) => <TextField {...params} />}
slotProps={{ listbox: { style: { padding: 0, maxHeight: '100px' } } }}
slots={{
popper: (props) => {
const { disablePortal, anchorEl, open, ...other } = props;
return <Box {...other} />;
},
}}
/>,
);
const textbox = screen.getByRole('combobox');
act(() => {
textbox.focus();
});
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });
fireEvent.keyDown(textbox, { key: 'ArrowDown' });

checkHighlightIs(screen.getByRole('listbox'), 'one');
expect(screen.getByRole('listbox')).to.have.property('scrollTop', 0);
},
);
checkHighlightIs(screen.getByRole('listbox'), 'one');
expect(screen.getByRole('listbox')).to.have.property('scrollTop', 0);
});

it('should keep the current highlight if possible', () => {
render(
Expand Down Expand Up @@ -1460,28 +1457,24 @@ describe('<Autocomplete />', () => {
expect(screen.getByRole('combobox')).to.have.property('value', '');
});

// Enable once https://github.com/jsdom/jsdom/issues/2898 is resolved
it.skipIf(isJsdom())(
'should fail validation if a required field has no value',
async function test() {
const handleSubmit = spy((event) => event.preventDefault());
const view = render(
<form onSubmit={handleSubmit}>
<Autocomplete
multiple
options={['one', 'two']}
renderInput={(params) => <TextField {...params} required />}
value={[]}
/>
<button type="submit">Submit</button>
</form>,
);
it('should fail validation if a required field has no value', async function test() {
const handleSubmit = spy((event) => event.preventDefault());
const view = render(
<form onSubmit={handleSubmit}>
<Autocomplete
multiple
options={['one', 'two']}
renderInput={(params) => <TextField {...params} required />}
value={[]}
/>
<button type="submit">Submit</button>
</form>,
);

await view.user.click(screen.getByRole('button', { name: 'Submit' }));
await view.user.click(screen.getByRole('button', { name: 'Submit' }));

expect(handleSubmit.callCount).to.equal(0);
},
);
expect(handleSubmit.callCount).to.equal(0);
});

// Enable once https://github.com/jsdom/jsdom/issues/2898 is resolved
// The test is passing in JSDOM but form validation is buggy in JSDOM so we rather skip than have false confidence
Expand Down
28 changes: 11 additions & 17 deletions packages/mui-material/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1874,21 +1874,18 @@ describe('<Select />', () => {
});

// https://github.com/mui/material-ui/issues/38700
it.skipIf(isJsdom())(
'should merge `slotProps.paper` with the default Paper props',
function test() {
render(
<Select MenuProps={{ slotProps: { paper: { 'data-testid': 'paper' } } }} open value="10">
<MenuItem value="10">Ten</MenuItem>
</Select>,
);
it('should merge `slotProps.paper` with the default Paper props', function test() {
render(
<Select MenuProps={{ slotProps: { paper: { 'data-testid': 'paper' } } }} open value="10">
<MenuItem value="10">Ten</MenuItem>
</Select>,
);

const paper = screen.getByTestId('paper');
const selectButton = screen.getByRole('combobox', { hidden: true });
const paper = screen.getByTestId('paper');
const selectButton = screen.getByRole('combobox', { hidden: true });

expect(paper.style).to.have.property('minWidth', `${selectButton.clientWidth}px`);
},
);
expect(paper.style).to.have.property('minWidth', `${selectButton.clientWidth}px`);
});

// https://github.com/mui/material-ui/issues/46273
it('should merge `slotProps.list` with default List props', () => {
Expand Down Expand Up @@ -2258,10 +2255,7 @@ describe('<Select />', () => {
});

describe('errors', () => {
// can't catch render errors in the browser for unknown reason
// tried try-catch + error boundary + window onError preventDefault
// TODO is this fixed?
it.skipIf(!isJsdom())('should throw if non array', function test() {
it('should throw if non array', function test() {
const errorRef = React.createRef();
expect(() => {
render(
Expand Down
55 changes: 25 additions & 30 deletions packages/mui-material/src/Slider/Slider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,44 +701,39 @@ describe.skipIf(!supportsTouch())('<Slider />', () => {
expect(screen.getByRole('slider')).not.to.have.attribute('tabIndex');
});

// TODO: Don't skip once a fix for https://github.com/jsdom/jsdom/issues/3029 is released.
it.skipIf(isJsdom())(
'should not respond to drag events after becoming disabled',
function test() {
const { setProps, container } = render(<Slider defaultValue={0} />);
it('should not respond to drag events after becoming disabled', function test() {
const { setProps, container } = render(<Slider defaultValue={0} />);

stub(container.firstChild, 'getBoundingClientRect').callsFake(() => ({
width: 100,
height: 10,
bottom: 10,
left: 0,
}));
stub(container.firstChild, 'getBoundingClientRect').callsFake(() => ({
width: 100,
height: 10,
bottom: 10,
left: 0,
}));

fireEvent.touchStart(
container.firstChild,
createTouches([{ identifier: 1, clientX: 21, clientY: 0 }]),
);
fireEvent.touchStart(
container.firstChild,
createTouches([{ identifier: 1, clientX: 21, clientY: 0 }]),
);

const thumb = screen.getByRole('slider');
const thumb = screen.getByRole('slider');

expect(thumb).to.have.attribute('aria-valuenow', '21');
expect(thumb).toHaveFocus();
expect(thumb).to.have.attribute('aria-valuenow', '21');
expect(thumb).toHaveFocus();

setProps({ disabled: true });
expect(thumb).not.toHaveFocus();
expect(thumb).not.to.have.class(classes.active);
setProps({ disabled: true });
expect(thumb).not.toHaveFocus();
expect(thumb).not.to.have.class(classes.active);

fireEvent.touchMove(
container.firstChild,
createTouches([{ identifier: 1, clientX: 30, clientY: 0 }]),
);
fireEvent.touchMove(
container.firstChild,
createTouches([{ identifier: 1, clientX: 30, clientY: 0 }]),
);

expect(thumb).to.have.attribute('aria-valuenow', '21');
},
);
expect(thumb).to.have.attribute('aria-valuenow', '21');
});

// TODO: Don't skip once a fix for https://github.com/jsdom/jsdom/issues/3029 is released.
it.skipIf(isJsdom())('is not focused (visibly) after becoming disabled', function test() {
it('is not focused (visibly) after becoming disabled', function test() {
const { setProps } = render(<Slider defaultValue={0} />);

const thumb = screen.getByRole('slider');
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-material/src/Slider/useSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ function focusThumb(
// Prevent pointer-driven focus rings in browsers that support this option.
// Chrome 144+ supports `focusVisible` in `HTMLElement.focus()` options.
focusVisible,
// Cast can be removed once TypeScript >= 6.0 (added `focusVisible` to lib.dom FocusOptions).
} as FocusOptions & { focusVisible?: boolean | undefined });
});
}
}
}
Expand Down
13 changes: 0 additions & 13 deletions packages/mui-material/src/TextField/TextField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ import type { FormHelperTextProps } from '@mui/material/FormHelperText';
slotProps={{ input: { classes: { inputTypeSearch: 'search-input' } } }}
/>
);
const standardOutlinedClassname = (
<TextField
variant="standard"
slotProps={{
input: {
// notchedOutline is only used with variant "outlined"
// FIXME this no longer generates an error in TS 3.2, see https://github.com/Microsoft/TypeScript/issues/28926
// classes: { inputTypeSearch: 'search-input', notchedOutline: 'notched-outline' }, // @ts-expect-error
},
}}
/>
);

const filled = (
<TextField
variant="filled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ describe('useAutocomplete', () => {

// can't catch render errors in the browser for unknown reason
// tried try-catch + error boundary + window onError preventDefault
// TODO is this fixed?
it.skipIf(!isJsdom())('should warn if the input is not bound', async () => {
function Test(props) {
const { options } = props;
Expand Down
Loading