Fix store item variant defaults and listing sorting

Auto-select first option in variation modals and sort store items by availability, then update time.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-18 11:26:20 +03:30
co-authored by Cursor
parent b861ab3dc1
commit 5f4b0b4f92
20 changed files with 409 additions and 64 deletions
@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from 'react'
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { Eraser, MoreHorizontal, Trash2, Users } from 'lucide-react'
import { fitFixedPopover } from '../utils/fitFixedPopover'
import styles from './BusinessActionsOverflowMenu.module.css'
type PopoverPosition = {
@@ -31,10 +32,11 @@ export function BusinessActionsOverflowMenu({
const rect = triggerRef.current?.getBoundingClientRect()
if (!rect) return
setPopoverPos({
top: rect.bottom + 8,
left: rect.right,
})
const size = popoverRef.current
? { width: popoverRef.current.offsetWidth, height: popoverRef.current.offsetHeight }
: { width: 220, height: 160 }
setPopoverPos(fitFixedPopover(rect, size, 'end'))
}
function toggleOpen() {
@@ -47,6 +49,11 @@ export function BusinessActionsOverflowMenu({
setOpen(true)
}
useLayoutEffect(() => {
if (!open) return
updatePopoverPosition()
}, [open])
useEffect(() => {
if (!open) return