Skip to content

Commit

Permalink
fix: feedback clementino smart one about expandable
Browse files Browse the repository at this point in the history
  • Loading branch information
matthprost committed Apr 3, 2024
1 parent bb8bc1a commit 33e40b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .changeset/itchy-maps-turn.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
"@ultraviolet/plus": patch
---

Fix `<Navigation />` to work better with slider, have better tab index and close the menu when clicking
- Fix `<Navigation />` to work better with slider, have better tab index and close the menu when clicking
- Fix `<EstimateCost />` to have prop `overlayMargin` in order to adapt the overlay depending on the width of the navigation
3 changes: 2 additions & 1 deletion .changeset/nervous-schools-smile.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
"@ultraviolet/ui": patch
---

Add `tabIndex` on `<Tooltip />` component to be able to disable tab when the children is already tabbable
- Add `tabIndex` on `<Tooltip />` component to be able to disable tab when the children is already tabbable
- Fix `<Expandable />` to add `visibility: hidden` when the component is collapsed to avoid tabulation on hidden elements
10 changes: 5 additions & 5 deletions packages/plus/src/components/Navigation/components/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,26 +330,26 @@ export const Item = ({
const PaddedStack = noExpand ? Stack : PaddingStack

const hasHrefAndNoChildren = href && !children
const haspinnedFeatureAndNoChildren =
const hasPinnedFeatureAndNoChildren =
pinnedFeature && !children && !noPinButton
const isItemPinned = pinnedItems.includes(label)
const shouldShowPinnedButton = useMemo(() => {
if (href || disabled) return false

if (pinnedItems.length >= pinLimit && type === 'default') return false

if (haspinnedFeatureAndNoChildren && type !== 'default') {
if (hasPinnedFeatureAndNoChildren && type !== 'default') {
return true
}

if (haspinnedFeatureAndNoChildren && !isItemPinned) {
if (hasPinnedFeatureAndNoChildren && !isItemPinned) {
return true
}

return false
}, [
disabled,
haspinnedFeatureAndNoChildren,
hasPinnedFeatureAndNoChildren,
href,
isItemPinned,
pinLimit,
Expand Down Expand Up @@ -474,7 +474,7 @@ export const Item = ({
</Stack>
</Stack>
<Stack direction="row" alignItems="center" gap={href ? 1 : undefined}>
{badgeText || haspinnedFeatureAndNoChildren ? (
{badgeText || hasPinnedFeatureAndNoChildren ? (
<>
{badgeText ? (
<StyledBadge
Expand Down
8 changes: 8 additions & 0 deletions packages/ui/src/components/Expandable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export const Expandable = ({
useEffect(() => {
if (opened && ref.current && height) {
ref.current.style.maxHeight = `${height}px`
if (!minHeight) {
ref.current.style.visibility = ''
}
transitionTimer.current = setTimeout(() => {
if (ref.current) {
ref.current.style.maxHeight = 'initial'
Expand All @@ -85,6 +88,11 @@ export const Expandable = ({
if (ref.current) {
ref.current.style.maxHeight = `${minHeight}px`
ref.current.style.overflow = 'hidden'
setTimeout(() => {
if (ref.current && !minHeight) {
ref.current.style.visibility = 'hidden'
}
}, ANIMATION_DURATION)
}
}, 0)
}
Expand Down

0 comments on commit 33e40b4

Please sign in to comment.