Skip to content

fix(empty): restore static image API and locale fallback#8506

Merged
tangjinzhou merged 2 commits intovueComponent:feat/vaporfrom
dajiangjunok:review/empty
Apr 3, 2026
Merged

fix(empty): restore static image API and locale fallback#8506
tangjinzhou merged 2 commits intovueComponent:feat/vaporfrom
dajiangjunok:review/empty

Conversation

@dajiangjunok
Copy link
Copy Markdown

Summary

This PR is part of the component review effort for feat/vapor, focused on Empty.

Main fixes:

  1. Restored static image API compatibility

    • Empty.PRESENTED_IMAGE_DEFAULT
    • Empty.PRESENTED_IMAGE_SIMPLE
  2. Restored built-in image behavior

    • image now supports built-in Empty image components, not only URL strings
    • simple image now correctly applies ant-empty-small
    • default/simple images now correctly apply ant-empty-normal
  3. Restored locale fallback behavior

    • default description now reads from ConfigProvider.locale.Empty.description
    • fallback text is aligned to No data
  4. Fixed image rendering priority

    • image prop takes precedence over image slot, matching expected component behavior
  5. Improved verification coverage

    • added tests for static image API
    • added tests for locale fallback
    • added tests for prop vs slot priority
    • updated snapshots after behavior fixes

Reviewed Areas

  • API compatibility
  • locale fallback
  • built-in image behavior
  • class/state mapping
  • test coverage
  • demo correctness

Validation

Passed:

npm --workspace @ant-design-vue/ui run test -- --run -u src/components/empty/__tests__/index.test.ts src/components/empty/__tests__/demo.test.ts

Co-authored-by: OpenAI Codex <codex@openai.com>
…mple variant

The default large SVG (184x152) should not get ant-empty-normal class which
sets image height to 40px. Only the simple/small variant needs this class.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tangjinzhou
Copy link
Copy Markdown
Member

Review: fix(empty): restore static image API and locale fallback

Positive

  • Good addition of Empty.PRESENTED_IMAGE_SIMPLE and Empty.PRESENTED_IMAGE_DEFAULT static APIs
  • markRaw() for static image components avoids unnecessary reactivity
  • Locale fallback via useConfigInject() aligns with other components
  • description: false to hide description works correctly
  • Good test coverage for all features

Must Fix (pushed)

  1. emptyClass applied ant-empty-normal to default variant — This class sets .ant-empty-image { height: 40px } which clips the default 184x152 SVG. Fixed: ant-empty-normal now only applies when imageVariant === 'simple'. Test assertion updated accordingly.

Consider

  • getImageVariant inspects VNode types from slots at runtime which is fragile. Consider only checking the image prop for variant markers and treating slots as 'custom'.
  • filterEmpty utility in types.ts could live in @/utils/ for reuse across components.

Pushed fix in commit 705a9ae.

@tangjinzhou tangjinzhou merged commit 5b48bfa into vueComponent:feat/vapor Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants