Skip to content

Commit

Permalink
fix(List): getting wrong tabIndex on initialization (#2648)
Browse files Browse the repository at this point in the history
  • Loading branch information
rivka-ungar authored Dec 12, 2024
1 parent 3c3fe12 commit 7aaaa73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ const List: VibeComponent<ListProps> & {
return child;
}
const id = (child.props as { id: string }).id || `${overrideId}-item-${index}`;
const isFocusableItem = isListItem(childrenRefs.current[index]);

const currentRef = childrenRefs.current[index];
const isFocusableItem = currentRef === undefined || currentRef === null || isListItem(currentRef);
return React.cloneElement(child, {
// @ts-ignore not sure how to deal with ref here
ref: ref => (childrenRefs.current[index] = ref),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`List renders correctly with list items 1`] = `
onFocus={[Function]}
onMouseEnter={[Function]}
role="option"
tabIndex={-1}
tabIndex={0}
>
1
</li>
Expand Down

0 comments on commit 7aaaa73

Please sign in to comment.