diff --git a/src/components/useList/hooks/useList.ts b/src/components/useList/hooks/useList.ts index 11a99c9eb4..80a2ea08f7 100644 --- a/src/components/useList/hooks/useList.ts +++ b/src/components/useList/hooks/useList.ts @@ -1,7 +1,7 @@ /* eslint-disable valid-jsdoc */ import React from 'react'; -import type {ListState, UseListResult} from '../types'; +import type {InitialListParsedState, ListState, UseListResult} from '../types'; import {useFlattenListItems} from './useFlattenListItems'; import {useListParsedState} from './useListParsedState'; @@ -9,7 +9,10 @@ import type {UseListParsedStateProps} from './useListParsedState'; import {useListState} from './useListState'; import type {UseListStateProps} from './useListState'; -interface UseListProps extends UseListParsedStateProps, UseListStateProps { +interface UseListProps + extends UseListParsedStateProps, + Omit { + initialState?: Partial; controlledState?: Partial; } @@ -30,16 +33,18 @@ export const useList = ({ defaultExpandedState, }); - const initValues = React.useMemo(() => { + const initValues: InitialListParsedState = React.useMemo(() => { return { expandedById: {...initialState.expandedById, ...initialValues?.expandedById}, selectedById: {...initialState.selectedById, ...initialValues?.selectedById}, disabledById: {...initialState.disabledById, ...initialValues?.disabledById}, + activeItemId: initialValues?.activeItemId, }; }, [ initialState.disabledById, initialState.expandedById, initialState.selectedById, + initialValues?.activeItemId, initialValues?.disabledById, initialValues?.expandedById, initialValues?.selectedById, diff --git a/src/components/useList/types.ts b/src/components/useList/types.ts index 6af991e373..8aa8a22f6f 100644 --- a/src/components/useList/types.ts +++ b/src/components/useList/types.ts @@ -90,7 +90,7 @@ export type ListState = { export type InitialListParsedState = Pick< ListState, - 'disabledById' | 'expandedById' | 'selectedById' + 'disabledById' | 'expandedById' | 'selectedById' | 'activeItemId' >; export type ItemSchema = {