Skip to content
Draft
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
6 changes: 4 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
".oxlintrc.json",
"**/*.ts",
"**/*.tsx",
"!.next/**",
"!**/dist/**",
"!**/build/**",
"!**/.turbo/**",
Expand All @@ -38,8 +39,9 @@
"files": {
"includes": [
"**",
"!**/.turbo/",
"!**/.next/",
"!.turbo/*",
"!**/.turbo/*",
"!**/.next/*",
"!**/coverage",
"!**/node_modules/",
"!**/storybook-static",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/DateInput/components/Popup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import type { Dispatch, ReactNode, RefObject, SetStateAction } from 'react'
import { useEffect, useRef } from 'react'
import { useLayoutEffect, useRef } from 'react'
import { Popup } from '../../Popup'
import { POPUP_WIDTH } from '../constants'
import { dateinputPopup } from './styles.css'
Expand Down Expand Up @@ -38,7 +38,7 @@ export const CalendarPopup = ({
}: PopupProps) => {
const ref = useRef<HTMLDivElement>(null)

useEffect(() => {
useLayoutEffect(() => {
document.addEventListener('mousedown', event =>
handleClickOutside(event, ref, setVisible, refInput),
)
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/LineChart/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getMinChartValue = (preppedData?: Serie[]): number => {
}

export const getCurrent = (values: number[] = []): number =>
values.length > 0 ? values[values.length - 1] : 0
values.length > 0 ? values.at(-1) : 0

export const getSelected = (
label: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Menu/MenuContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const Menu = forwardRef(
if (indexOfCurrent > 0) {
listItem[indexOfCurrent - 1].focus()
} else {
listItem[listItem.length - 1].focus()
listItem.at(-1).focus()
}
} else if (event.key === 'ArrowLeft' && triggerMethod === 'hover') {
disclosureRef.current?.focus()
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Modal/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const Dialog = ({
}

const firstFocusableEl = focusableEls[0] as HTMLElement
const lastFocusableEl = focusableEls[focusableEls.length - 1] as HTMLElement
const lastFocusableEl = focusableEls.at(-1) as HTMLElement

if (event.shiftKey) {
if (
Expand Down
42 changes: 21 additions & 21 deletions packages/ui/src/components/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
useEffect,
useId,
useImperativeHandle,
useLayoutEffect,
useMemo,
useRef,
useState,
Expand Down Expand Up @@ -58,7 +59,7 @@ export type PositionsType = {
}

/**
* This event handle allow us to not bubble the event to document.body like this react-select works fine
* This event handle allow us to not bubble the event to document.body like this select works fine
*/
const stopClickPropagation: MouseEventHandler = event => {
event.nativeEvent.stopImmediatePropagation()
Expand Down Expand Up @@ -182,6 +183,7 @@ export const Popup = forwardRef(
useImperativeHandle(ref, () => innerPopupRef.current as HTMLDivElement)

const timer = useRef<ReturnType<typeof setTimeout>>(undefined)

const popupPortalTarget = useMemo(() => {
if (portalTarget) {
return portalTarget
Expand All @@ -204,8 +206,7 @@ export const Popup = forwardRef(
}

return null
// oxlint-disable react/exhaustive-deps
}, [portalTarget, role, childrenRef.current])
}, [portalTarget, role])

// There are some issue when mixing animation and maxHeight on some browsers, so we disable animation if maxHeight is set.
const animationDuration =
Expand All @@ -227,17 +228,18 @@ export const Popup = forwardRef(
)

const generatePopupPositions = useCallback(() => {
if (childrenRef.current && innerPopupRef.current) {
setPositions(
computePositions({
align,
childrenRef,
hasArrow,
placement,
popupPortalTarget: popupPortalTarget as HTMLElement,
popupRef: innerPopupRef,
}),
)
console.debug('generatePopupPositions')
if (childrenRef.current && innerPopupRef.current && popupPortalTarget) {
const position = computePositions({
align,
childrenRef,
hasArrow,
placement,
popupPortalTarget,
popupRef: innerPopupRef,
})
setPositions(prevPosition => ({ ...prevPosition, ...position }))
console.debug({ ...position })
}
}, [hasArrow, placement, popupPortalTarget, align])

Expand Down Expand Up @@ -350,7 +352,7 @@ export const Popup = forwardRef(
* Once popup is visible in the dom we can compute positions, then set it visible on screen and add event to
* recompute positions on scroll or screen resize.
*/
useEffect(() => {
useLayoutEffect(() => {
if (visibleInDom) {
generatePopupPositions()

Expand Down Expand Up @@ -379,12 +381,11 @@ export const Popup = forwardRef(
])

// This will be triggered when positions are computed and popup is visible in the dom.
useEffect(() => {
useLayoutEffect(() => {
if (visibleInDom && innerPopupRef.current) {
innerPopupRef.current.style.opacity = '1'
}
// oxlint-disable react/exhaustive-deps
}, [positions])
}, [positions, visibleInDom])

/**
* If popup has `visible` prop it means the popup is manually controlled through this prop.
Expand Down Expand Up @@ -439,6 +440,7 @@ export const Popup = forwardRef(
visibleInDom,
innerPopupRef,
childrenRef,
id,
hideOnClickOutside,
])

Expand All @@ -463,9 +465,7 @@ export const Popup = forwardRef(
}

const firstFocusableEl = focusableEls[0] as HTMLElement
const lastFocusableEl = focusableEls[
focusableEls.length - 1
] as HTMLElement
const lastFocusableEl = focusableEls.at(-1) as HTMLElement

if (event.shiftKey) {
if (
Expand Down
Loading
Loading