Skip to content

Commit

Permalink
Michal's review
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 20, 2024
1 parent 9548c2d commit 35fa94a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/mui-joy/src/ListItem/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import NestedListContext from '../List/NestedListContext';
import RowListContext from '../List/RowListContext';
import WrapListContext from '../List/WrapListContext';
import ComponentListContext from '../List/ComponentListContext';
import ListSubheaderDispatch from '../ListSubheader/ListSubheaderContext';
import ListSubheaderContext from '../ListSubheader/ListSubheaderContext';
import GroupListContext from '../List/GroupListContext';

const useUtilityClasses = (ownerState: ListItemOwnerState) => {
Expand Down Expand Up @@ -244,7 +244,7 @@ const ListItem = React.forwardRef(function ListItem(inProps, ref) {
});

return (
<ListSubheaderDispatch.Provider value={setSubheaderId}>
<ListSubheaderContext.Provider value={setSubheaderId}>
<NestedListContext.Provider value={nested ? subheaderId || true : false}>
<SlotRoot {...rootProps}>
{startAction && <SlotStartAction {...startActionProps}>{startAction}</SlotStartAction>}
Expand All @@ -265,7 +265,7 @@ const ListItem = React.forwardRef(function ListItem(inProps, ref) {
{endAction && <SlotEndAction {...endActionProps}>{endAction}</SlotEndAction>}
</SlotRoot>
</NestedListContext.Provider>
</ListSubheaderDispatch.Provider>
</ListSubheaderContext.Provider>
);
}) as OverridableComponent<ListItemTypeMap>;

Expand Down
6 changes: 3 additions & 3 deletions packages/mui-joy/src/ListSubheader/ListSubheader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { spy } from 'sinon';
import { createRenderer } from '@mui-internal/test-utils';
import { ThemeProvider } from '@mui/joy/styles';
import ListSubheader, { listSubheaderClasses as classes } from '@mui/joy/ListSubheader';
import ListSubheaderDispatch from './ListSubheaderContext';
import ListSubheaderContext from './ListSubheaderContext';
import describeConformance from '../../test/describeConformance';

describe('Joy <ListSubheader />', () => {
Expand Down Expand Up @@ -50,9 +50,9 @@ describe('Joy <ListSubheader />', () => {
it('should call dispatch context with the generated id', () => {
const dispatch = spy();
const { container } = render(
<ListSubheaderDispatch.Provider value={dispatch}>
<ListSubheaderContext.Provider value={dispatch}>
<ListSubheader />
</ListSubheaderDispatch.Provider>,
</ListSubheaderContext.Provider>,
);

// @ts-ignore
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-joy/src/ListSubheader/ListSubheader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/base/composeClas
import { styled, useThemeProps } from '../styles';
import { ListSubheaderOwnerState, ListSubheaderTypeMap } from './ListSubheaderProps';
import { getListSubheaderUtilityClass } from './listSubheaderClasses';
import ListSubheaderDispatch from './ListSubheaderContext';
import ListSubheaderContext from './ListSubheaderContext';
import useSlot from '../utils/useSlot';
import { INVERTED_COLORS_ATTR } from '../colorInversion/colorInversionUtils';

Expand Down Expand Up @@ -88,7 +88,7 @@ const ListSubheader = React.forwardRef(function ListSubheader(inProps, ref) {
...other
} = props;
const id = useId(idOverride);
const setSubheaderId = React.useContext(ListSubheaderDispatch);
const setSubheaderId = React.useContext(ListSubheaderContext);

React.useEffect(() => {
if (setSubheaderId) {
Expand Down
6 changes: 3 additions & 3 deletions packages/mui-joy/src/ListSubheader/ListSubheaderContext.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';

const ListSubheaderDispatch = React.createContext<
const ListSubheaderContext = React.createContext<
undefined | React.Dispatch<React.SetStateAction<string>>
>(undefined);

if (process.env.NODE_ENV !== 'production') {
ListSubheaderDispatch.displayName = 'ListSubheaderDispatch';
ListSubheaderContext.displayName = 'ListSubheaderContext';
}

export default ListSubheaderDispatch;
export default ListSubheaderContext;

0 comments on commit 35fa94a

Please sign in to comment.