@s-ui/react-molecule-tabs
Advanced tools
Comparing version 2.27.0 to 2.28.0
# CHANGELOG | ||
# 2.28.0 (2021-11-22) | ||
### Bug Fixes | ||
* **components/molecule/tabs:** Fix scroll into active tab breaking when is out of the viewport ([970bb62](https://github.com/SUI-Components/sui-components/commit/970bb62a81849e3dcffba277fc76062ef9435af8)) | ||
### Features | ||
* **components/molecule/tabs:** Refactor to use mergeRefs hook ([775871a](https://github.com/SUI-Components/sui-components/commit/775871ad0ef230c9a4aeda50a716dbecc81c0490)) | ||
# 2.27.0 (2021-11-03) | ||
@@ -4,0 +18,0 @@ |
@@ -1,5 +0,6 @@ | ||
import { useEffect } from 'react'; | ||
import { useEffect, useRef } from 'react'; | ||
import cx from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import { useOnScreen } from '@s-ui/react-hooks'; | ||
import useMergeRefs from '@s-ui/react-hooks/lib/useMergeRefs'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
@@ -31,2 +32,4 @@ import { jsxs as _jsxs } from "react/jsx-runtime"; | ||
var innerRef = useRef(); | ||
var handleChange = function handleChange(ev) { | ||
@@ -40,3 +43,3 @@ !disabled && onChange(ev, { | ||
if (active && isIntersecting) { | ||
outerRef.current.scrollIntoView({ | ||
innerRef.current.scrollIntoView({ | ||
behavior: 'smooth', | ||
@@ -47,3 +50,3 @@ block: 'nearest', | ||
} | ||
}, [active, outerRef, isIntersecting]); | ||
}, [active, innerRef, isIntersecting]); | ||
var className = cx(CLASS_TAB, (_cx = {}, _cx[CLASS_TAB_ACTIVE] = active, _cx[CLASS_TAB_DISABLED] = disabled, _cx)); | ||
@@ -53,3 +56,3 @@ return /*#__PURE__*/_jsxs("li", { | ||
onClick: handleChange, | ||
ref: outerRef, | ||
ref: useMergeRefs(innerRef, outerRef), | ||
children: [icon && /*#__PURE__*/_jsx("span", { | ||
@@ -56,0 +59,0 @@ className: CLASS_TAB_ICON, |
{ | ||
"name": "@s-ui/react-molecule-tabs", | ||
"version": "2.27.0", | ||
"version": "2.28.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
33475
164