medusajs/medusa

[Bug]: Admin UI: When editing Inventory Item attributes, Linked variants disappear

Closed

#14,782 创建于 2026年2月18日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)TypeScript (22,539 star) (2,090 fork)batch import
good first issuetype: bugversion: 2.0

描述

Package.json file

{
  "name": "",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "license": "MIT",
  "keywords": [
    "medusa",
    "ecommerce",
    "vix-detailing"
  ],
  "scripts": {
    "build": "medusa build",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "start": "medusa start",
    "dev": "medusa develop",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
  },
  "dependencies": {
    "@medusajs/admin-sdk": "2.13.1",
    "@medusajs/cli": "2.13.1",
    "@medusajs/framework": "2.13.1",
    "@medusajs/medusa": "2.13.1",
    "@tiptap/core": "^3.19.0",
    "@tiptap/extension-color": "^3.19.0",
    "@tiptap/extension-link": "^3.19.0",
    "@tiptap/extension-placeholder": "^3.19.0",
    "@tiptap/extension-text-align": "^3.19.0",
    "@tiptap/extension-text-style": "^3.19.0",
    "@tiptap/extension-underline": "^3.19.0",
    "@tiptap/pm": "^3.19.0",
    "@tiptap/react": "^3.19.0",
    "@tiptap/starter-kit": "^3.19.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "2.13.1",
    "@swc/core": "^1.7.28",
    "@swc/jest": "^0.2.36",
    "@types/cors": "^2.8.19",
    "@types/jest": "^29.5.13",
    "@types/node": "^20.12.11",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.4.14"
  },
  "engines": {
    "node": ">=20"
  },
  "packageManager": "yarn@4.12.0"
}

Node.js version

v20.18.1

Database and its version

PostgreSQL 16 - alpine

Operating system name and version

Windows 11 25H2

Browser name

No response

What happended?

After editing inventory item attributes (height, width, etc.) via the edit drawer, the "Associated Variants" section disappears from the inventory detail page. It only reappears after ~90 seconds (the staleTime window) or a full page refresh.

Expected behavior

Inventory item associated variants do not disappear on editing the inventory item attributes

Actual behavior

Inventory item associated variantsdisappear on editing the inventory item attributes, when waiting 90 seconds and performing another edit, the associated variants widget comes back with correct values

Suggested fix

I got this to work by making a change in src/hooks/api/inventory.tsx to include query in the query key:

export const useInventoryItem = (id, query?, options?) => {
  const { data, ...rest } = useQuery({
    queryFn: () => sdk.admin.inventoryItem.retrieve(id, query),
    queryKey: inventoryItemsQueryKeys.detail(id),  // ← query NOT in key
    ...options,
  })
  return { ...data, ...rest }
}

贡献者指南