From 28ed4c84929b770553e5da2f0b4b0b14787ed530 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 12 Jan 2022 10:44:52 +0100 Subject: [PATCH] use onSelect from Tabs --- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index 740dfae507..3c791d1c1b 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -36,7 +36,7 @@ export const TabsUI = (props: TabsUIProps) => { const classNameImg = 'my-1 mr-1 text-dark ' + tab.iconClass const classNameTab = 'nav-item nav-link d-flex justify-content-center align-items-center px-2 py-1 tab' + (index === currentIndexRef.current ? ' active' : '') return ( -
{ props.onSelect(index); currentIndexRef.current = index; setSelectedIndex(index) }} ref={el => { tabsRef.current[index] = el }} className={classNameTab} title={tab.tooltip}> +
{ tabsRef.current[index] = el }} className={classNameTab} title={tab.tooltip}> {tab.icon ? () : ()} {tab.title} { props.onClose(index); event.stopPropagation() }}> @@ -88,6 +88,11 @@ export const TabsUI = (props: TabsUIProps) => { tabsElement.current = domEl tabsElement.current.addEventListener('wheel', transformScroll) }} + onSelect={(index) => { + props.onSelect(index) + currentIndexRef.current = index + setSelectedIndex(index) + }} > {props.tabs.map((tab, i) => {renderTab(tab, i)})}