Skip to content

Commit

Permalink
Fix tab reference
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Jan 26, 2023
1 parent 29f6344 commit 0c92f3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions code/ui/components/src/tabs/tabs.hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function useList(list: ChildrenList) {
style={{ visibility: 'hidden' }}
tabIndex={-1}
ref={(ref: HTMLButtonElement) => {
tabRefs.current.set(title, ref);
tabRefs.current.set(id, ref);
}}
className="tabbutton"
type="button"
Expand Down Expand Up @@ -134,8 +134,8 @@ export function useList(list: ChildrenList) {
let widthSum = 0;

const newInvisibleList = list.filter((item) => {
const { title } = item;
const tabButton = tabRefs.current.get(title);
const { id } = item;
const tabButton = tabRefs.current.get(id);

if (!tabButton) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions code/ui/components/src/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ export const Tabs: FC<TabsProps> = memo(
<Wrapper absolute={absolute} bordered={bordered} id={htmlId}>
<WrapperChildren backgroundColor={backgroundColor}>
<TabBar ref={tabBarRef} role="tablist">
{visibleList.map(({ title, id, active, color }, index) => {
{visibleList.map(({ title, id, active, color }) => {
return (
<TabButton
id={`tabbutton-${sanitize(title)}`}
ref={(ref: HTMLButtonElement) => {
tabRefs.current.set(title, ref);
tabRefs.current.set(id, ref);
}}
className={`tabbutton ${active ? 'tabbutton-active' : ''}`}
type="button"
Expand Down

0 comments on commit 0c92f3a

Please sign in to comment.