medusajs/medusa

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

クローズ

#14,782 opened on 2026/02/18

 (4 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (2,090 件のフォーク)batch import
good first issuetype: bugversion: 2.0

Repository metrics

Stars
 (22,539 個のスター)
PR merge metrics
 (平均マージ 10d 22h) (30d で 185 merged PRs)

説明

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 }
}

コントリビューターガイド