Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cyan-toes-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ebay/ui-core-react": patch
---

prevent onSelect from firing on initial render
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ describe("<EbayTabs>", () => {
});
});

describe("on initial render", () => {
it("should not fire onSelect", () => {
const spy = vi.fn();
render(<DefaultTabs onSelect={spy} />);
expect(spy).not.toHaveBeenCalled();
});
});

describe("on tab click", () => {
let spy, tabs;

Expand Down
6 changes: 1 addition & 5 deletions packages/ebayui-core-react/src/ebay-tabs/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { cloneElement, FC, KeyboardEvent, useEffect, useState } from "react";
import React, { cloneElement, FC, KeyboardEvent, useState } from "react";
import classNames from "classnames";

import { handleActionKeydown, handleLeftRightArrowsKeydown } from "../common/event-utils";
Expand Down Expand Up @@ -61,10 +61,6 @@ const Tabs: FC<TabsProps> = ({
});
};

useEffect(() => {
handleSelect(index);
}, [index]);

const isLarge = size === "large";

const tabHeadings = filterByType(children, Tab).map((item, i) =>
Expand Down
Loading