From 07a16c959198bedfa45dbb14b5ad804bd11a6d82 Mon Sep 17 00:00:00 2001 From: Isaev Alexandr Date: Mon, 15 Jul 2024 10:14:43 +0300 Subject: [PATCH] fix(ListItemView): div -> li default list item html tag (#1698) --- .../TreeList/__stories__/stories/WithDndListStory.tsx | 1 + .../useList/__stories__/components/ListWithDnd.tsx | 1 + .../useList/components/ListItemView/ListItemView.tsx | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/TreeList/__stories__/stories/WithDndListStory.tsx b/src/components/TreeList/__stories__/stories/WithDndListStory.tsx index ee4d963a23..22bcb3827d 100644 --- a/src/components/TreeList/__stories__/stories/WithDndListStory.tsx +++ b/src/components/TreeList/__stories__/stories/WithDndListStory.tsx @@ -28,6 +28,7 @@ const DraggableListItem = ({ {...provided?.draggableProps} ref={provided?.innerRef} {...props} + role="option" /> ); }; diff --git a/src/components/useList/__stories__/components/ListWithDnd.tsx b/src/components/useList/__stories__/components/ListWithDnd.tsx index ab20c12c61..1ffde3968d 100644 --- a/src/components/useList/__stories__/components/ListWithDnd.tsx +++ b/src/components/useList/__stories__/components/ListWithDnd.tsx @@ -98,6 +98,7 @@ export const ListWithDnd = ({size, itemsCount, 'aria-label': ariaLabel}: ListWit dragging={snapshot.isDragging} ref={provided.innerRef} endSlot={} + role="option" /> )} diff --git a/src/components/useList/components/ListItemView/ListItemView.tsx b/src/components/useList/components/ListItemView/ListItemView.tsx index 49d647a137..83caf482ff 100644 --- a/src/components/useList/components/ListItemView/ListItemView.tsx +++ b/src/components/useList/components/ListItemView/ListItemView.tsx @@ -15,7 +15,7 @@ import './ListItemView.scss'; const b = block('list-item-view'); -export interface ListItemViewProps +export interface ListItemViewProps extends QAProps, ListItemCommonProps { /** @@ -93,7 +93,7 @@ const renderSafeIndentation = (indentation?: number) => { }; export const ListItemView = React.forwardRef(function ListItemView< - T extends React.ElementType = 'div', + T extends React.ElementType = 'li', >( { id, @@ -120,7 +120,7 @@ export const ListItemView = React.forwardRef(function ListItemView< }: ListItemViewPropsWithTypedAttrs, ref?: ListItemViewRef, ) { - const as: React.ElementType = asProps || 'div'; + const as: React.ElementType = asProps || 'li'; const isGroup = typeof expanded === 'boolean'; const onClick = disabled ? undefined : _onClick; const activeOnHover = @@ -201,7 +201,7 @@ export const ListItemView = React.forwardRef(function ListItemView< {endSlot} ); -}) as ({ +}) as ({ ref, ...props }: ListItemViewPropsWithTypedAttrs & {ref?: ListItemViewRef}) => React.ReactElement;