Skip to content

Commit 3873d43

Browse files
authored
Merge pull request #1921 from ethereum/use_onSelect_Tabs
use onSelect from Tabs
2 parents 6480e57 + 28ed4c8 commit 3873d43

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const TabsUI = (props: TabsUIProps) => {
3636
const classNameImg = 'my-1 mr-1 text-dark ' + tab.iconClass
3737
const classNameTab = 'nav-item nav-link d-flex justify-content-center align-items-center px-2 py-1 tab' + (index === currentIndexRef.current ? ' active' : '')
3838
return (
39-
<div onClick={() => { props.onSelect(index); currentIndexRef.current = index; setSelectedIndex(index) }} ref={el => { tabsRef.current[index] = el }} className={classNameTab} title={tab.tooltip}>
39+
<div ref={el => { tabsRef.current[index] = el }} className={classNameTab} title={tab.tooltip}>
4040
{tab.icon ? (<img className="my-1 mr-1 iconImage" src={tab.icon} />) : (<i className={classNameImg}></i>)}
4141
<span className="title-tabs">{tab.title}</span>
4242
<span className="close-tabs" onClick={(event) => { props.onClose(index); event.stopPropagation() }}>
@@ -88,6 +88,11 @@ export const TabsUI = (props: TabsUIProps) => {
8888
tabsElement.current = domEl
8989
tabsElement.current.addEventListener('wheel', transformScroll)
9090
}}
91+
onSelect={(index) => {
92+
props.onSelect(index)
93+
currentIndexRef.current = index
94+
setSelectedIndex(index)
95+
}}
9196
>
9297
<TabList className="d-flex flex-row align-items-center">
9398
{props.tabs.map((tab, i) => <Tab className="py-1" key={tab.name}>{renderTab(tab, i)}</Tab>)}

0 commit comments

Comments
 (0)