fixes #4365 --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c0d0f8d78d
commit
99f8f8fedb
@ -2,6 +2,12 @@ import { ReactNode, useEffect, useRef } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
export type SelectableItemProps = {
|
||||
itemId: string;
|
||||
@ -27,8 +33,8 @@ export const SelectableItem = ({
|
||||
}, [isSelectedItemId]);
|
||||
|
||||
return (
|
||||
<div className={className} ref={scrollRef}>
|
||||
<StyledContainer className={className} ref={scrollRef}>
|
||||
{children}
|
||||
</div>
|
||||
</StyledContainer>
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
import {
|
||||
useRecoilCallback,
|
||||
useResetRecoilState,
|
||||
useSetRecoilState,
|
||||
} from 'recoil';
|
||||
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
||||
|
||||
import { useSelectableListStates } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListStates';
|
||||
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
|
||||
@ -24,16 +20,11 @@ export const useSelectableList = (selectableListId?: string) => {
|
||||
selectableListOnEnterState,
|
||||
);
|
||||
|
||||
const resetSelectedItemIdState = useResetRecoilState(selectedItemIdState);
|
||||
|
||||
const resetSelectedItem = () => {
|
||||
resetSelectedItemIdState();
|
||||
};
|
||||
|
||||
const handleResetSelectedPosition = useRecoilCallback(
|
||||
const resetSelectedItem = useRecoilCallback(
|
||||
({ snapshot, set }) =>
|
||||
() => {
|
||||
const selectedItemId = getSnapshotValue(snapshot, selectedItemIdState);
|
||||
|
||||
if (isDefined(selectedItemId)) {
|
||||
set(selectedItemIdState, null);
|
||||
set(isSelectedItemIdSelector(selectedItemId), false);
|
||||
@ -44,11 +35,9 @@ export const useSelectableList = (selectableListId?: string) => {
|
||||
|
||||
return {
|
||||
selectableListId: scopeId,
|
||||
|
||||
setSelectableItemIds,
|
||||
isSelectedItemIdSelector,
|
||||
setSelectableListOnEnter,
|
||||
resetSelectedItem,
|
||||
handleResetSelectedPosition,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user